posted 14 years ago
Hi
1. In hibernate orm concepts are seems like similar to the database relational linking, where as what is the advantage of having orm because we have the database relational technique so why would i need to go for orm
2. in hibernat association for many to one like user_master table user id have lot of expense id in expense_master table and i have done all mapping like i pasted the code below so my question is
while i am fetching the user i can get all expense detals but while inserting the expense, shall i need load the user in expense pojo ? same when i inser user do i need to set any expense objects?
if any links or words to explain association please let me know it bit confusing
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 19, 2009 8:17:22 AM by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
<class name="ZuserDetail" table="zUSER_DETAIL" schema="dbo" catalog="EMONITERING">
<id name="userId" type="int">
<column name="USER_ID" />
<generator class="assigned" />
</id>
<property name="username" type="string">
<column name="USERNAME" length="500" />
</property>
<property name="password" type="string">
<column name="PASSWORD" length="2000" />
</property>
<property name="dob" type="timestamp">
<column name="DOB" length="23" />
</property>
<property name="email" type="string">
<column name="EMAIL" length="200" />
</property>
<property name="paddress" type="string">
<column name="PADDRESS" length="1000" />
</property>
<property name="caddress" type="string">
<column name="CADDRESS" length="1000" />
</property>
<property name="status" type="java.lang.Character">
<column name="STATUS" length="1" />
</property>
<property name="createTimeStamp" type="timestamp">
<column name="CREATE_TIME_STAMP" length="23" />
</property>
<set name="loginDatas" inverse="true" lazy="true" table="LOGIN_DATA" fetch="select">
<key>
<column name="USER_ID" />
</key>
<one-to-many class="LoginData" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 19, 2009 8:17:22 AM by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
<class name="LoginData" table="LOGIN_DATA" schema="dbo" catalog="EMONITERING">
<id name="loginTypeId" type="int">
<column name="LOGIN_TYPE_ID" />
<generator class="assigned" />
</id>
<many-to-one name="zuserDetail" class="ZuserDetail" fetch="select">
<column name="USER_ID" />
</many-to-one>
<property name="loginType" type="string">
<column name="LOGIN_TYPE" length="50" />
</property>
<property name="username" type="string">
<column name="USERNAME" length="50" />
</property>
<property name="password" type="binary">
<column name="PASSWORD" />
</property>
<property name="status" type="java.lang.Character">
<column name="STATUS" length="1" />
</property>
<property name="createdTimeStamp" type="timestamp">
<column name="CREATED_TIME_STAMP" length="23" />
</property>
</class>
</hibernate-mapping>
Thanks
Sathish kumar
SCJP, SCWCD