Community
Participate
Working Groups
Build Identifier: I3622I20110617_20110617_1025 Metamodel generation in Dali does not produce the correct results. It seems that an OpenJPA 2.0.2 snapshot is used. The problem occurs when the entity class contains a byte[] array field. The metamodel generation produces a SingularAttribute for that. After starting the application we get an exception with that SingularAttribute. Using an external OpenJPA 2.1 for the metamodel generation produces the correct ListAttribute. Reproducible: Always Steps to Reproduce: 1. Generate metamodel for a simple Entity bean: @Entity public class MyEntity implements Serializable { private byte[] byteArray; private static final long serialVersionUID = 1L; public MyEntity() { super(); } public byte[] getByteArray() { return this.byteArray; } public void setByteArray(byte[] byteArray) { this.byteArray = byteArray; } } 2. The metamodel looks like: @Generated(value="Dali", date="2011-06-23T16:28:03.000-0400") @StaticMetamodel(MyEntity.class) public class MyEntity_ { public static volatile SingularAttribute<MyEntity, byte[]> byteArray; }
Actually please disregard the OpenJPA 2.0.2 part.
The JPA spec states the following in section 6.2.1: For every persistent non-collection-valued attribute y declared by class X, where the type of y is Y, the metamodel class must contain a declaration as follows: public static volatile SingularAttribute<X, Y> y; 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.List, then public static volatile ListAttribute<X, Z> z; A byte[] is not a Collection (or List). The bug is in your runtime (OpenJPA 2.1?) throwing an exception.
Seems like an oversight in OpenJPA which handles all arrays as collections (well lists). I've opened an issue with OpenJPA to address this problem : https://issues.apache.org/jira/browse/OPENJPA-2025
Resolving as invalid.