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

update

 
james edwin
Ranch Hand
Posts: 393
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am able to successfully insert the record in two tables(table A and B)

TABLE A.hbm.xml is as follows: -
******************************************************************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="test" table="TestA">
<id name="queId" type="string" unsaved-value="null">
<column name="QUE_ID" sql-type="char(7)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="queDescX">
<column name="QUE_DESC" sql-type="char(40)" not-null="true"/>
</property>
<one-to-one name="testb" class="TestB" cascade="all"/>
</class>
</hibernate-mapping>

**********************************************************

TABLE B.hbm.xml is as follows :-

**********************************************************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="testB" table="TestB">
<id name="qd" type="string" unsaved-value="any">
<column name="QUE_ID" sql-type="char(7)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="emailAddr">
<column name="EMAIL_ADDR" sql-type="char(256)" />
</property>
</class>
</hibernate-mapping>

**********************************************************

Everything works fine in case of Insert.

But incase of update,hibernate is trying to insert again record in Table B instead of update.I called "update()" method instead of save()in java code.

****************************
sess.update(AB);
*****************************

Why this is not working ?..

Regards,

James
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we need more info.
Though a call to update should never insert, if you called saveOrUpdate I'd wonder whether you assigned the primary key.
Anyway, strange, but post the relevant code please.
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh and maybe the generated sql as well.
 
james edwin
Ranch Hand
Posts: 393
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still working on different combinations. Once i get an success,I will update you guys !!!
 
pascal betz
Ranch Hand
Posts: 547
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi James


what is unsaved-value="any" for ?
i could not find a description of this.

pascal
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic