-->
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.  [ 3 posts ] 
Author Message
 Post subject: Lifecycle method call.
PostPosted: Wed Oct 29, 2003 9:59 am 
Newbie

Joined: Thu Oct 23, 2003 10:55 am
Posts: 11
Hello,

I need to implement a class where the instance need to embed the creation date and the last modification date.
Regarding the documentation, the Lifecycle implementation seems to be exactly what i need. So imagine the following class:
Code:
public class Foo implements  Lifecycle
{
    /**
     * The Class Log.
     */
    private static Log log = LogFactory.getLog(Foo.class);
    ...
    public boolean onSave(Session arg0) throws CallbackException
    {
        log.debug("onSave()");
        return NO_VETO;
    }
    public boolean onUpdate(Session arg0) throws CallbackException
    {
        log.debug("onUpdate()");
        return NO_VETO;
    }
    public boolean onDelete(Session arg0) throws CallbackException
    {
        log.debug("onDelete()");
        return NO_VETO;
    }
    public void onLoad(Session arg0, Serializable arg1)
    {
        log.debug("onLoad()");
    }
    ...
}

Now I have the following code:
Code:
Transaction tx = session.currentTransaction();
Foo foo = // ... creating or retrieving the object, depending of the context.
session.save(foo); // To have the same code for modification or creation
tx.commit();

When the object is created, there is no problem, the method onSave() is called, but when modified, the nor onSave() nor onUpdate() (that is normal) are called.
Does anybody have a possible explanation - I use Hibernate 2.0.3?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 10:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Please read the JavaDoc for Lifecycle. This is expected behaviour. There is no onFlushDirty() event of the Lifecycle interface.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 10:22 am 
Newbie

Joined: Thu Oct 23, 2003 10:55 am
Posts: 11
The event callback onFlushDirty() is available in the Interceptor interface, that is global to all the persistent objects.
Do you know another solution of using the Interceptor to manage these date transparently (without using the Session.update() method)?
Thanks in advance.

MG


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