db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Jefferson <a...@jpox.org>
Subject Re: Thoughts about JDO 2.1 Annotation
Date Tue, 16 Jan 2007 19:42:48 GMT
> Same for @Serialized and @Dependent, @Index and @Unique
> (mainly for collections, but maybe also for maps when keys and values
> should share the same setting, or maybe @Serialized and @Dependent should
> only cover map values and @Index and @Unique only map keys).

@Serialized is a valid annotation to add but not for what you're suggesting. 
It should serialise the whole field. If the field is not a container this 
makes no difference but it does for containers (maps/collections/arrays). If 
the field is a collection then the whole collection would be serialised with 
this annotations. This is different to serialising the element only. Best 
visualised with the case (with an RDBMS) and you want a join table and you 
have a List and want to serialise the element into one column of the join 
table. This is where @Element(serialized="true") is used - so the join table 
has 3 columns ... an FK back to the owner, a List order, and a serialised 
element. Similarly for Maps ... @Serialized would serialise the map as a 
whole, whereas @Key(serialized="true")/@Value(serialized="true") would 
serialise the key/value into any join table. The distinction is important.

I'm against the @Index/@Unique on an array/collection/map field implying 
things regarding indexing the element/key/value. Just doesn't work for maps 
and I don't like the assumptions that the JPA spec makes.

I'm also against having an @Dependent annotation since maps have 2 components, 
and JPA falls apart on this one too [Its @Cascade applies to Value only, so 
what happens when a key needs cascading ? undefined!]


-- 
Andy

Mime
View raw message