aspose file tools*
The moose likes Object Relational Mapping and the fly likes update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "update" Watch "update" New topic
Author

update

james edwin
Ranch Hand

Joined: Nov 22, 2001
Posts: 393
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


Regards,
James
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
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

Joined: Mar 26, 2002
Posts: 442
oh and maybe the generated sql as well.
james edwin
Ranch Hand

Joined: Nov 22, 2001
Posts: 393
I am still working on different combinations. Once i get an success,I will update you guys !!!
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
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
 
subject: update