Community
Participate
Working Groups
Transformation mapping ignores the @Column annotation applied to the field if the @Column is specified outside the @WriteTransformer annotation. For instance, @Column annotation gets ignored below : @Entity @Table(name="LOCATION_MAP") public class LocationMap implements Serializable { @Transformation @ReadTransformer(IPAttributeTransformer.class) @WriteTransformer(IPAttributeTransformer.class) @Column(name="IP_ADDR") protected String ipAddr; ... }
Working on submitting a fix and for this issue.
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
Created attachment 225744 [details] Proposed fix for this bug. Proposed Fix : To throw a ValidationException in above case. With current fix, if an entity "Employee" contains : @WriteTransformer(method="getStime") @Column(name="TIME") private Time stime; the exception raised will be : Exception Description: Predeployment of PersistenceUnit [default] failed. Internal Exception: Exception [EclipseLink-7356] (Eclipse Persistence Services - 2.5.0.qualifier): org.eclipse.persistence.exceptions.ValidationException Exception Description: Entity class [class bug.Employee] must specify @Column annotation within @WriteTransformer annotation for attribute stime. Tests added : No. Attempted adding a test, but this will cause predeployment errors and the persistence unit will not load. Adding an automated test will break the tests, hence not added. Tests done : Manual testing for negative and positive case as below Negative case (Error seen) - @WriteTransformer(method="getStime") @Column(name="TIME") private Time stime; Positive case (No error)- @WriteTransformer(method="getStime", column=@Column(name="TIME")) Other tests : ant -f antbuild.xml test-jpa : got 100% success.
Out of fear of being too restrictive (when we could support both configurations) and perhaps breaking existing users, I think it is best to look for the second @Column definition and use it if it is defined. I small change to the WriteTransformer constructor would do this, that is: /** * INTERNAL: * Used for annotation loading. */ public WriteTransformerMetadata(MetadataAnnotation writeTransformer, MetadataAccessor accessor) { super(writeTransformer, accessor); Object column = writeTransformer.getAttribute("column"); if (column != null) { m_column = new ColumnMetadata((MetadataAnnotation) column, accessor); } else { m_column = new ColumnMetadata(accessor.getAccessibleObject().getAnnotation(MetadataConstants.JPA_COLUMN), accessor); } } This would then allow users both options to specifying the column.
Thank you for the feedback. Will re-submit modified patch with the feedback incorporated.
Created attachment 226671 [details] Modified patch and testcase Sorry for the delay. Uploaded new proposed patch with suggested change from Guy Pelletier and testcase added to AdvancedJPAJunitTest. JPA tests passed. Thank you for reviewing.
Problem description: @Column annotation was being ignored silently in WriteTransformerMetadata. Only column attribute was considered. Fix Description: In org.eclipse.persistence.internal.jpa.metadata.transformers.WriteTransformerMetadata contructor - WriteTransformerMetadata(MetadataAnnotation writeTransformer, MetadataAccessor accessor), only column attribute is read. Changed this as below - if column attribute provided use this attribute else if column annotation is provided, use the column annotation. Tests added : In AdvancedJunitJPATest, added a test - testTransformationMappingWithColumnAnnotation to test @WriteTransformer annotation with @Column annotation specified outside. Other case with column attribute specified already exists. Testing done : "ant -f antbuild.xml test-jpa" produced 100% success
Fixed in master (2.5) at: 0f71573e3f226b56f9850e3714e151e6a67e4404 2.4.x branch checkin pending.
Checked into 2.4.x branch (2.4.2) at: ec3d7e7949308ecf7c3ec5c041ca64d3530f39a5
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink