-->
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.  [ 2 posts ] 
Author Message
 Post subject: NewBie ON Hibernate Can't save
PostPosted: Mon Nov 21, 2005 1:51 am 
Newbie

Joined: Thu Jan 06, 2005 7:19 am
Posts: 1
Location: bangkok
Table
Mproduct
product_id int
name
price
Mproduct_config_value
desc_id int
product_id int
value
Mproduct_config_desc
desc_id int
name
descript

Mapping
Code:
<set name="configDescObjBridge" lazy="true" inverse="true" table="mproduct_config_value" cascade="all" order-by="PRODUCT_ID">
         <key column="PRODUCT_ID"/>
         <composite-element class="com.cubetech.bus.bean.associate.BridgeConfigDesc">
            <parent name="product"/>            
            <many-to-one name="desc" column="DESC_ID" class="MproductConfigDesc" not-null="true"/>
            <property name="value" insert="true" update="true" column="VALUE" not-null="true" type="java.lang.String"/>
         </composite-element>
      </set>

Code
Code:
         _RootDAO.initialize();
         SessionFactory sf = _RootDAO.getSessionFactory();
         Session session = sf.openSession();
         Transaction tx = null;
         tx = session.beginTransaction();
         Mproduct prod = (Mproduct)session.load(Mproduct.class, new Integer(1));
         for(BridgeConfigDesc bridge:prod.getConfigDescObjBridge()){         
            System.out.println(bridge.getDesc().getId());
            if(bridge.getDesc().getId()==3){               
               bridge.setValue("test");
            }
         }
         
         session.saveOrUpdate(prod);
         tx.commit();
         session.flush();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 3:11 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Not sure whether this solves your problem.

The line
Code:
session.saveOrUpdate(prod);

is wrong. See chapter 11.5. Modifying persistent objects of the reference manual.

HTH
Ernst


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

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.