-->
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.  [ 6 posts ] 
Author Message
 Post subject: setId() in bean and saveOrUpdate
PostPosted: Fri Mar 12, 2004 9:38 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
I've such strange (may be not) situation: when my bean has public method setId() and i use saveOrUpdate on newly instantiated bean I get UPDATE expression (that's wrong of course). But when i remove this method or change it's signature to protected all is OK (I get SELECT expression). What's wrong?
Sorry for my English...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 9:49 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Sorry for mistake...
I get INSERT expression is second situation...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 10:44 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Here's log:

2004-03-12 17:45:12,825 DEBUG engine.Cascades - id unsaved-value strategy NULL
2004-03-12 17:45:12,825 DEBUG impl.SessionImpl - saveOrUpdate() previously saved
instance with id:
2004-03-12 17:45:12,825 DEBUG impl.SessionImpl - updating [com.amfitel.dp.bl.DPD
emandHBImpl#]
2004-03-12 17:45:12,841 DEBUG transaction.JDBCTransaction - commit
2004-03-12 17:45:12,841 DEBUG impl.SessionImpl - flushing session
2004-03-12 17:45:12,841 DEBUG impl.SessionImpl - Flushing entities and processin
g referenced collections
2004-03-12 17:45:12,841 DEBUG impl.SessionImpl - Updating entity: [com.amfitel.d
p.bl.DPDemandHBImpl#]
2004-03-12 17:45:12,856 DEBUG impl.SessionImpl - Processing unreferenced collect
ions
2004-03-12 17:45:12,856 DEBUG impl.SessionImpl - Scheduling collection removes/(
re)creates/updates
2004-03-12 17:45:12,856 DEBUG impl.SessionImpl - Flushed: 0 insertions, 1 update
s, 0 deletions to 1 objects
2004-03-12 17:45:12,856 DEBUG impl.SessionImpl - Flushed: 0 (re)creations, 0 upd
ates, 0 removals to 0 collections


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Show the offending code (ie the set)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 2:18 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Code:
public interface AObject
{
   String getId();
   void setId(String id);
...
}
public abstract class AbstractAObject implements AObject
{
   public String getId()
   {
      return id;
   }

   public void setId(String id)
   {
      this.id = id;
   }
...
}
public class DPDemandHBImpl extends AbstractDPDemand (extends AbstractAObject)
{

....
}
<class name="DPDemandHBImpl" table="DP_DEMANDS" lazy="true" >
<id name="id" type="string" unsaved-value="null" >
<column name="ID" sql-type="number" not-null="true"/>
<generator class="com.amfitel.common.hb.StringSequenceGenerator">
<param name="sequence" >DP_DEMANDS_SEQ</param>
</generator>
</id>
<property name="num" type="string" />
<property name="createDate" type="date" column="CR_DATE" />
<property name="descr" type="com.amfitel.common.hb.StringClobType" >
</property>
<many-to-one name="creator" column="CREATOR_ID" not-null="true" class="DPUserJDBCImpl" />
</class>



In Struts' action I'm create this object by Factory pattern and then call saveOrUpdate method...
Code:
         DPDemand demand=null;

         demand=DPObjectFactory.getInstance().
            getDemand().create();
         demand.setCreateDate(new Date());
         demand.setCreator((DPUser)req.getUserPrincipal());

         log.debug("demand=" + demand);
         BeanUtils.copyProperties(demand, form);
         demand.save();



Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 12:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Post it to jira in a very simple but workable testcase, please.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.