Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Hibernate 3.0

 
Greenhorn
Posts: 4
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • 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!
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic