Bug 433 : Ebean doesn't honor @Transient for non-primitive array properties
Priority 
Medium
Reported Version 
 
Logged By 
Dave Brokaw
Status 
Fixed
Fixed Version 
github
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
13/11/2012
Updated 
13/11/2012
Type 
Bug
 
Attachments 
No attachments

Create a class with a non-primitive array property, e.g. "MyObject[] myObjects" labeled with @Transient.
Compile the class and instrument it with Ebean weaver.

At runtime, Ebean fails to load with the following exception:

Caused by: java.lang.IllegalArgumentException: field [myObjects] not found in [com.xxx.MyContainer][id]
at com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect.getFieldIndex(EnhanceBeanReflect.java:139)
at com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect.getGetter(EnhanceBeanReflect.java:143)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setBeanReflect(BeanDescriptorManager.java:1377)
... 52 more

Workarounds:
1. Change the property to a List or Set rather than array.
2. Mark the field with "transient" as well if possible, i.e. if you don't need to use Java serialization on the field.

Fix: Move the "return new DeployBeanPropertyAssocOne(desc, propertyType);" statement inside the "if (!isTransientField(field)){" block in DeployCreateProperties.createProp(), and return null if the field is marked @Transient, rather than assuming it is a persistent OneToOne.

 
woResponse

Upload a file