This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate 3.0

 
devil devil
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic