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

Gunnar Morling gunnar at hibernate.org
Mon Feb 3 09:29:08 EST 2014


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

> On 3 February 2014 12:12, Gunnar Morling <gunnar at hibernate.org> wrote:
> > 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.
>
> That's a problem, we need to remove it.
> I can help making the Infinispan tests but  would be nice if you could
> start removing the non-serializable members, or track it as a separate
> issue. That would help me a lat, as I fear I've got a bit out of touch
> with that area of OGM.
>

Created https://hibernate.atlassian.net/browse/OGM-435 for it. Thanks for
having an eye on that test. If you need any support with that let me know.

>
> >>
> >> >
> >> > 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.
>
> I guess it's a matter of habits. If I see a class declaring
> "Serializable" it (personally) affects my design considerations.
>

Yes, sure. But the question is what's the intention of making  a given type
serializable; for me it was surprising that AssociationKey is used as is
and passed to a datastore, so far I only perceived it as type which is used
*within* OGM and its dialects which then create the right representation to
persist that info (hence my original question).

If AssociationKey and friends are actually designed to be used themselves
in the stores, we should document that, in particular since we must take
care when evolving these types.


>
> Sanne
>
> >
> > 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