Instantiation « Interceptor « JPA Q&A





1. beware: Interceptor.instantiate must set id    forum.hibernate.org

If you implement net.sf.hibernate.Interceptor, your implementation of the instantiate method must set the id of the object it returns (if it returns an object). The id is passed to instantiate, as a Serializable parameter. I neglected to set the id in my implementation of Interceptor.instantiate. I saw no ill effect with Hibernate 2.0.2. But when I attempted to upgrade to Hibernate ...

2. Interceptor.instantiate & setting the identifier    forum.hibernate.org

I just ran into the issue with my custom Interceptor.... After browsing through the source code I noticed that with SessionImpl.java has the following instantiate method: public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException { Object result = interceptor.instantiate( persister.getEntityName(), id ); if ( result == null ) result = persister.instantiate( id ); return result; } This is great that I ...

3. Interceptor.instantiate & setting the identifier    forum.hibernate.org

I just ran into the issue with my custom Interceptor.... After browsing through the source code I noticed that with SessionImpl.java has the following instantiate method: public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException { Object result = interceptor.instantiate( persister.getEntityName(), id ); if ( result == null ) result = persister.instantiate( id ); return result; } This is great that I ...

4. Interceptor.instantiate and default constructors    forum.hibernate.org

I'd love to provide a patch, but I'm not sure what the expected behavior should be. Given that current code assumes non-interface classes should have default ctors, and that if they don't they fail early (i.e., at persister creation), I'm not sure if the correct behavior (for everyone) should be to only fail if the constructor is needed and not available, ...

5. Question about efficiency of interceptor instantiate method    forum.hibernate.org

The instantiate method's signature is: public Object instantiate(String entityName, EntityMode entityMode, Serializable id) Inside the method, I'm supposed to call the desired constructor, set the ID, and return the result. I get that. What I don't get is why is a string passed in instead of a Class? I have to reflect the string to a Class on every call. That ...

6. Interceptor.instantiate for injecting entities    forum.hibernate.org

Newbie Joined: Fri Oct 17, 2008 7:01 pm Posts: 2 Location: San Francisco Hi, I wrote an Interceptor with an instantiate that uses a Guice injector to construct entity objects. I'm seeing Hibernate call the default constructor on the entity object anyway, so it's not always using Interceptor.instantiate to do the work. What are these default-construct objects for? What functions might ...