[hibernate-dev] [OGM] When is AssociationKey serialized?

Gunnar Morling gunnar at hibernate.org
Mon Feb 3 07:12:48 EST 2014


2014/2/3 Sanne Grinovero <sanne at hibernate.org>

> If you store anything in Infinispan, it should at the very least be
> Serializable.
>
> A better solution would be to provide custom Externalizers:
> https://hibernate.atlassian.net/browse/OGM-37


Ah, I see. I like the Externalizer approach as I found it surprising that
AK implements Serializable as there apparently is no need for it from the
perspective of the core engine itself.

>
>
> On 3 February 2014 10:56, Gunnar Morling <gunnar at hibernate.org> wrote:
> > Hi,
> >
> > I'm wondering why org.hibernate.ogm.grid.AssociationKey implements
> > Serializable. When is it actually serialized?
>
> When you use Infinispan in clustered mode.
>
> >
> > I'm suspecting the answer is "never", as the type of the "metadata"
> member
> > is not serializable, so I'd expect a NotSerializableException to be
> raised.
>
> Our problem is probably that we don't have integration tests using
> Infinispan in modes other than "Local".
> I suspect I avoided making them as they make the testsuite slower, but
> it seems you just highlighted an important reason to add them :-/


Ok, I've created https://hibernate.atlassian.net/browse/OGM-434 for adding
a test for this scenario. I'm still wondering how it supposed to work given
that AssociationKey contains a non-serializable non-transient member.


> >
> > If so, does anything speak against making AssociationKey not implement
> > Serializable?
>
> It's needed. Also I think it's an important "warning flag" in terms of
> design: never consider hooking references to services in such a key,
> and strive to keep it as a very simple value holder.
>

Hum, not sure whether making a type Serializable is the right way to
indicate such a matter. But of course the requirement stands as is for
Infinispan as you describe, at least unless that Externalizer-based
approach gets implemented.

Thanks for the clarification,

--Gunnar



>
> -- Sanne
>
> >
> > Thanks,
> >
> > --Gunnar
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list