-->
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: Why is the Session.isDirty methnot working as I would expect
PostPosted: Fri Dec 23, 2005 9:27 am 
Newbie

Joined: Fri Dec 16, 2005 9:28 am
Posts: 2
I have a detached object.
I make changes to the detached object.
I then reattach the object using session.lock(LockMode.NONE)
I then call session.isDirty() and expect to get a "true" result but I get "false" even though the object is dirty.

Once I have the session open and then make changes to the object, I can call isDirty and get a "true" result.

What am I doing wrong?

Here is an example along with output:

try{
UserInfoFactory.getInstance().initialize(new TestUserInfoObject());

InterfaceDAO inf = new InterfaceDAO();

BigInteger bi = new BigInteger("52538");
List l = inf.findByInterfaceHeaderId(bi);
InterfaceEntry e = (InterfaceEntry)l.get(0);
System.out.println("e.assyPartNum is initially = " + e.getAssyPartNum());
e.setAssyPartNum("test1");
System.out.println("e.assyPartNum is now = " + e.getAssyPartNum());
Session s = HibernateHelper.openSession();
s.lock(e,LockMode.NONE);
System.out.println("Is dirty (it should be true)? " + s.isDirty());
e.setAssyPartNum("test2");
System.out.println("e.assyPartNum is now = " + e.getAssyPartNum());

System.out.println("Is dirty? " + s.isDirty());
HibernateHelper.closeSession();
}catch(Exception ex){
ex.printStackTrace();
}

OUTPUT
===============================================
e.assyPartNum is initially = d
e.assyPartNum is now = test1
Is dirty (it should be true)? false
e.assyPartNum is now = test2
Is dirty? true


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.