[hibernate-dev] Session factory name & clustering

Scott Marlow smarlow at redhat.com
Mon Nov 10 11:07:18 EST 2014


On 11/10/2014 07:40 AM, Steve Ebersole wrote:
> It would depend on what is inside the CacheKey, which is the key object
> Hibernate passes to the second-level cache.  Usually this situation
> comes up with the identifier Type(s), especially in the case of
> composite identifiers.  Some of the Type implementations hold reference
> to the SessionFactory.  Serializing those properly depends on being able
> to resolve the proper SessionFactory reference on deser, which can
> happen based on UUID (same JVM) or name (across JVMs).
>
> On Mon, Nov 10, 2014 at 4:17 AM, Galder Zamarreño <galder at redhat.com
> <mailto:galder at redhat.com>> wrote:
>
>     Hi all,
>
>     Re:
>     http://stackoverflow.com/questions/26110918/infinispan-marshalling-error-for-hibernate-entity-with-composite-primary-key

This user found the "hibernate.session_factory_name" + 
"hibernate.session_factory_name_is_jndi" settings and HHH-6822.

>     Re: https://github.com/hibernate/hibernate-orm/pull/820
>
>     Seems like the issue is resolved by making sure Session Factories
>     have the same name.
>
>     Is this something new? I’ve never had the need to set it in order to
>     get Hibernate 2LC clustered tests working. None of my unit tests set
>     the session factory name. One of my most recent demos uses JPA, and
>     never had to set hibernate.session_factory_name property.
>
>     Or is this due to the peculiarity of the Entity the user has? I’ve
>     run some tests locally and SessionFactoryImpl.readResolve() does not
>     seem to get called.

If the local test serializes the SF UUID and then deserializes from the 
same JVM, the test should pass (as long as the same Hibernate 
classloader is used).  If you are involving multiple JVMs, the SF UUIDs 
are local to each JVM, so you should see failures when deserializing on 
a different JVM (as the SF UUID lookup will fail).

>
>     @Paul/@Scott, have you seen anything similar before?

For EE container deployments, we set the 
"hibernate.session_factory_name" if the application doesn't.  We set it 
to an application scoped unique name (deployment archive name (including 
sub-deployment reference) and the persistence unit name).

>
>     Cheers,
>     --
>     Galder Zamarreño
>     galder at redhat.com <mailto:galder at redhat.com>
>     twitter.com/galderz <http://twitter.com/galderz>
>
>
>     _______________________________________________
>     hibernate-dev mailing list
>     hibernate-dev at lists.jboss.org <mailto:hibernate-dev at lists.jboss.org>
>     https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>



More information about the hibernate-dev mailing list