-->
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: Interceptor and Class-IDs.
PostPosted: Thu Nov 25, 2004 11:19 am 
Newbie

Joined: Mon Nov 22, 2004 8:07 am
Posts: 4
Hi

Hibernate version: 2.1.4

my problem:

I wrote my own hibernate-interceptor. The code:

Code:
public class DBInterceptor implements Interceptor, Serializable {
    ....

    public Object instantiate(final Class clazz, final Serializable serial)
        throws CallbackException {

        return StorageFactoryFactory.
            getFactory().newObject(ObjectState.RESTORE, clazz);
    }

}


And now the problem: The db-id-attribute of new objects is not set. If i change the method to 'return null;' the db-id-attribute is set by hibernate. What is my failure? Do i have to set the id manually and how can i do this?

Regards
Andr


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 25, 2004 11:46 am 
Newbie

Joined: Mon Nov 22, 2004 8:07 am
Posts: 4
Aah.

I have the answer.... The solution sleeps in a clear parameter list...

Code:
public Object instantiate(final Class clazz, final Serializable id)  {

    return StorageFactoryFactory.
        getFactory().newObject(ObjectState.RESTORE, clazz, (Long) id);

}


Very easy.

Thanks
Andr


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.