-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping a collection with <set> - update problem
PostPosted: Thu Aug 10, 2006 7:28 am 
Newbie

Joined: Sat Jul 22, 2006 1:47 pm
Posts: 11
Hi,

I have two tables called BDA_CUSTOMER and BDA_ACCOUNT.
One customer can have many accounts. My application retrieves data fine.
But when I try to update a customer I do not get the intended results.
Customer data gets saved successfully.
But my Account data does not get saved.

This is the sql which is being run by Hibernate.
update BDA_ACCOUNTS set CUST_ID=? where CUST_ID=? and ACC_ID=?.

But my BDA_ACCOUNTS tables has another column for BALANCE. Why does not hibernate include balance column in SQL.


[a]Hibernate version: 3.0

Mapping documents:

===============================================

<class name="data.Customer" table="BDA_CUSTOMER">

<id name="custRef" type="string" column="CUST_ID" unsaved-value="null">
<generator class="sequence">
<param name="sequence">SEQ_CUSTOMER_IDS</param>
</generator>
</id>

<property name="name">
<column name="NAME"/>
</property>
<property name="status">
<column name="STATUS_ID"/>
</property>

<set name="accountsList" table="BDA_ACCOUNTS">

<key>
<column name="CUST_ID"/>
</key>

<one-to-many class="data.Account"/>
</set>

</class>

<class name="data.Account" table="BDA_ACCOUNTS">

<composite-id>
<key-property name="accId">
<column name="ACC_ID"/>
</key-property>

<key-property name="custRef">
<column name="CUST_ID"/>
</key-property>

</composite-id>

<property name="balance">
<column name="BALANCE"/>
</property>

</class>
================================================

[b]Code between sessionFactory.openSession() and session.close():

boolean is_updated = false;
Session session = null;
SessionFactory sessionFactory = null;

try
{

sessionFactory = new Configuration().setProperty("hibernate.show_sql", "true").configure().buildSessionFactory();
session =sessionFactory.openSession();
session.saveOrUpdate(CustomerObj);
is_updated = true;
}
catch(Exception e)
{
e.printStackTrace();
throw new ARException(BusinessErrorConstants.ERROR_SYSTEM);
}
finally
{
session.flush();
session.close();
}

[b]Full stack trace of any exception that occurs:


Name and version of the database you are using:
Oracle 8

The generated SQL (show_sql=true):
update BDA_ACCOUNTS set CUST_ID=? where CUST_ID=? and ACC_ID=?

Thanking You,
Chamal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.