-->
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: saveOrUpdate and Update method not working
PostPosted: Sat Aug 25, 2007 4:17 am 
Beginner
Beginner

Joined: Mon Aug 13, 2007 2:37 am
Posts: 22
Hey guys,

I'm trying to write data to a foreign key field using hibernate's 'saveOrUpdate' method, but it fails to write to my foreign key field. I tried using hibernate's 'update' method, but it does not work either. So, I wondering what I'm doing wrong.

The following is my code:

<hibernate-mapping>
<class name="com.PBCoreApp.datamodel.BusinessCbo" table="Busines" schema="dbo" catalog="PB">
<id name="businessId" type="java.lang.Integer">
<column name="Business_Id" />
<generator class="identity"></generator>
</id>

....

<many-to-one name="placeOfBusiness" class="com.PBCoreApp.datamodel.PlaceOfBusinessCbo" fetch="select">
<column name="Place_Of_Business_Id" />
</many-to-one>
</class>
</hibernate-mapping>

-----------------------------------

<hibernate-mapping>
<class name="com.PBCoreApp.datamodel.PlaceOfBusinessCbo" table="Place_Of_Business" schema="dbo" catalog="PB">
<id name="placeOfBusinessId" type="java.lang.Integer">
<column name="Place_Of_Business_Id" />
<generator class="identity"></generator>
</id>
<set name="busineses" inverse="true" cascade="all-delete-orphan">
<key>
<column name="Place_Of_Business_Id" />
</key>
<one-to-many class="com.PBCoreApp.datamodel.BusinessCbo" />
</set>
</class>
</hibernate-mapping>

-------------------------------------
JAVA CODE
-------------------------------------

public void saveOrUpdate(BusinessCbo businessCbo) {

this.getHibernateTemplate().saveOrUpdate(businessCbo);
this.getHibernateTemplate().flush();
this.getHibernateTemplate().clear();

}

-----------------------------------------

placeOfBusinessCbo = placeOfBusinessDao.findById(pobId);

businessCbo.setPlaceOfBusiness(placeOfBusinessCbo);

businessDao.saveOrUpdate(businessCbo);

-------------------------------------------------------------

Pls...Help!!!


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.