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
|