aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate 3.0" Watch "Hibernate 3.0" New topic
Author

Hibernate 3.0

devil devil
Greenhorn

Joined: Feb 13, 2006
Posts: 4
<class name="Event" table="abc" >
<id name="fid" type="long" unsaved-value="100">
<column name="ID" sql-type="int"/>
<generator class="assigned"/>
</id>

<property name="name"/>

<set name="listValue" cascade="save-update" inverse="true" lazy="false">
<key column="fid" />
<one-to-many class="foreign1"/>
</set>

</class>

<class name="foreign1" table="xyz" >

<id name="id" type="long" unsaved-value="100">
<column name="id" sql-type="int"/>
<generator class="sequence"/>
</id>

<property name="address" type="string" >
<column name="ADDRESS" sql-type="varchar2"/>
</property>

<property name="fid" type="long" >
<column name="fid" sql-type="int"/>
</property>

<many-to-one name="eve" column="fid" class="Event" update="false" insert="false" not-null="true" lazy="proxy"/>

</class>


this is mapping document.

problem i am facing is that
when i execute

Event testEvent = new Event();
java.util.Set forList = new java.util.HashSet();
testEvent.setFid(65);
forList.add(new foreign1("test",1, 65, testEvent));
testEvent.setListValue(forList);
session.save();
tx.commit();
It is genearting two
SQL statements

Hibernate: insert into abc (name, ID) values (?, ?)
Hibernate: update xyz set ADDRESS=?, fid=? where id=?
fid is a foreign key

i want that it should genrate two sql insert statements for both table when it is saving record. but it is not doing so it is trying to update table xyz. please resolve it.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

"devil devil"

Welcome to JavaRanch!

Please could you update your display name so it conforms with our Naming Policy. You can change it here. Thanks!


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate 3.0