<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 5.3//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-5.3.dtd">
<hibernate-mapping>
<class name="bean.Student" table="studentdb2">
<id name="roll" column="s_roll">
<generator class="assigned"/>
</id>
<property name="name"/>
<property name="course"/>
<property name="fees"/>
<property name="contact"/>
</class>
</hibernate-mapping>
=======================================================================
1. <hibernate-mapping>: Mapping file start by this tag.
We can map multiple bean class inside one <hibernate-mapping> tags according to the requirements.
2. <class name="bean.Student" table="studentdb2"> : This tags is used to map the bean class to the DB Table.
-->table="studentdb2" - It is optional. If we don't use then HB bydefault map bean class to the DB Table by SAME Name as your POJO/Bean class name.
-->In my case "Student" bean class will map to the "studentdb2" DB Table.
3.
<id name="roll" column="s_roll">
<generator class="assigned"/>
</id>
<id> tag is used to define the primary key on the DB Table.
Here
->name="roll" - roll is my bean class member variable.
->column="s_roll" - s_roll is my DB Table column which is define as Primary Key. It is Optional. If we don't use
then HB bydefault map to same as varaible name.
<generator class="assigned"/>: It is optional. We will discuss later about generator classes.
4. <property name="name"/> :
It is used to map the bean class variable to the noram DB Table column.
Also we can use by below:
<property name="name" column="s_name"/>: Here name variable map to the s_name column.
If we don't use column attribute then HB bydefault map to same as varaible name.
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 5.3//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-5.3.dtd">
<hibernate-mapping>
<class name="bean.Student" table="studentdb2">
<id name="roll" column="s_roll">
<generator class="assigned"/>
</id>
<property name="name"/>
<property name="course"/>
<property name="fees"/>
<property name="contact"/>
</class>
</hibernate-mapping>
=======================================================================
1. <hibernate-mapping>: Mapping file start by this tag.
We can map multiple bean class inside one <hibernate-mapping> tags according to the requirements.
2. <class name="bean.Student" table="studentdb2"> : This tags is used to map the bean class to the DB Table.
-->table="studentdb2" - It is optional. If we don't use then HB bydefault map bean class to the DB Table by SAME Name as your POJO/Bean class name.
-->In my case "Student" bean class will map to the "studentdb2" DB Table.
3.
<id name="roll" column="s_roll">
<generator class="assigned"/>
</id>
<id> tag is used to define the primary key on the DB Table.
Here
->name="roll" - roll is my bean class member variable.
->column="s_roll" - s_roll is my DB Table column which is define as Primary Key. It is Optional. If we don't use
then HB bydefault map to same as varaible name.
<generator class="assigned"/>: It is optional. We will discuss later about generator classes.
4. <property name="name"/> :
It is used to map the bean class variable to the noram DB Table column.
Also we can use by below:
<property name="name" column="s_name"/>: Here name variable map to the s_name column.
If we don't use column attribute then HB bydefault map to same as varaible name.
No comments:
Post a Comment