This is in continuation of my previous post.
Lets take the hibernate mapping file and get to the tags used in that file.
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="hib.Contact" table="CONTACT"> <id name="id" type="long" column="ID" > <generator/> </id> <property name="firstName"> <column name="FIRSTNAME" /> </property> <property name="lastName"> <column name="LASTNAME"/> </property> <property name="email"> <column name="EMAIL"/> </property> </class> </hibernate-mapping>
We could see some XML tags tries forms this mapping. Their explanations are given below.
Root element of this mapping
maps the java class and SQL table
This will handle the primary key constraint. In addition this is the unique representation of an object.
Attributes of ID elements are given below.
The property name used by the persistent class.
The column used to store the primary key value.
The Java data type used.
This is the value used to determine if a class has been made persistent. If the value of the id attribute is null, then it means that this object has not been persisted.
This is the notification to generate the primary key. The following values to this attribute decides the type of generator
generate primary keys of type long, short or int that are unique only. It should not be used in the clustered deployment environment.
Hibernate can also use the sequences to generate the primary key. It can be used with DB2, PostgreSQL, Oracle, SAP DB databases.
Assigned method is used when application code generates the primary key.
The property elements define standard Java attributes and their mapping into database schema. The property element supports the column child element to specify additional properties, such as the index name on a column or a specific column type