openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: Metamodel generates ListAttribute for arrays instead of SingularAttribute
Date Wed, 29 Jun 2011 18:09:35 GMT
It's interesting that you think that complying with the spec is a weak
argument.

Say that another vendor, or third party tools have a different
interpretation of the spec. Maybe one of those third party tools generated
your metamodel classes, would be a fair assumption that you'd have to
regenerate the classes to use OpenJPA?

The relevant wording in the spec is:
For every persistent collection-valued attribute z declared by class X,
where the element type
of z is Z, the metamodel class must contain a declaration as follows:
• if the collection type of z is java.util.Collection, then
public static volatile CollectionAttribute<X, Z> z;
• if the collection type of z is java.util.Set, then
public static volatile SetAttribute<X, Z> z;
• if the collection type of z is java.util.List, then
public static volatile ListAttribute<X, Z> z;
• if the collection type of z is java.util.Map, then
public static volatile MapAttribute<X, K, Z> z;
where K is the type of the key of the map in class X

I don't see wording in the spec to suggest that we can consider arrays as
Lists, nor is there wording that says we can't. My first read of the section
above, is that we should treat an array as a singular attribute, but this
isn't my area of expertise either.

To give you a more concrete example, would you consider a byte array a list
of bytes?

Say you have something like this:
@Lob
private byte[] pic;

What would you expect in the metamodel class?
public static volatile ListAttribute<ByteArrayEntity,Byte> pic; // this is
what OpenJPA currently generates
or
public static volatile SingularAttribute<ByteArrayEntity,byte[]> pic; // off
the top of my head - might not be fully baked

-mike


On Wed, Jun 29, 2011 at 10:58 AM, Pinaki Poddar <ppoddar@apache.org> wrote:

> > At any rate, this seems wrong to me
> what exactly is *this* that seems wrong? That arrays are special lists that
> does not grow? Or something else? Please elaborate -- and please except
> rather weak argument of 'JPA spec says so...'
>
> -----
> Pinaki
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Metamodel-generates-ListAttribute-for-arrays-instead-of-SingularAttribute-tp6529049p6529561.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message