wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Hibernate - How to save multiple entities in single transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate - How to save multiple entities in single transactions" Watch "Hibernate - How to save multiple entities in single transactions" New topic
Author

Hibernate - How to save multiple entities in single transactions

Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
Hi All,
Thanks for your replies. One more question on Hibernate mapping..

I have a Class, TestClass with fields
field1
field2....
....
...filed6.

I have mapped this class to two tables with two differnt entity names

<class name="com.something.TestClass " table="TEST_TABLE" entity-name="TestTableTestClass">
<id name="filed1" column="FIELD1" />
<property name="filed2" column="FIELD2" />
<property name="filed5" column="FIELD5" />

</class>
and some fileds to second table with different entity name
<class name="com.something.TestClass " table="TEST_TABLE_OTHER" entity-name="TestTableOtherTestClass">
<id name="filed2" column="FIELD2" />
<property name="filed4" column="FIELD4" />
<property name="filed5" column="FIELD5" />

</class>

Now my requirement is save entries to both the tables in single transaction,



But unfotunately its saving only the first save. i.e TestTableTestClass enitity to corresponding table. If change the order then also only first save is working and second is not.

Neither its throwing any error.... Not sure whats the error.

Can somebody help me....
Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
Hi, did i post this in wrong forum ? Shouldn't it be under Object relational Mapping
 
 
subject: Hibernate - How to save multiple entities in single transactions
 
Similar Threads
Help Needed....
sample code discrimination feature.
What's the correct way of writing HQL for ResultTransformer?
Hibernate Issue
How to join two tables having each two fileds in common? (seems like @OneToMany with 2 joinColumns)