|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
JPA: Override a property attribute in a subclassHi,
I have a subclass of a JPA entity, superclass that I cannot modify, but I need to mark some fields (in the subclass) with: @Column(updatable = false, insertable = false) because I need to use another property in the subclass that manage this field, but I cannot modify the superclass to make it to add @MappedSuperclass. I have tried adding @AttributeOverride annotation in the subclass like this: @AttributeOverride(name = "paisDespacho", column = @Column(name = "PaisDespacho", updatable = false, insertable = false)) But it seems that do nothing, when I run the application the exception says: ... Exception [EclipseLink-48] (Eclipse Persistence Services - 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.DescriptorException Exception Description: Multiple writable mappings exist for the field [FASTTRACK2.Despachos.PaisDespacho]. Only one may be defined as writable, all others must be specified read-only. ... "PaisDespacho" is a field with a propery named "paisDespacho" in the superclass with type "String", but in the subclass I need to create a new property that manage this field with type "Paises" (mappet to another entity). I cannot have access to modify the superclass. Please help. Thanks. xavier. |
|
|
Re: JPA: Override a property attribute in a subclassThe JPA spec seems to indicate that AttributeOverride only applies to MappedSuperclass and Embedded, is your superclass an Entity? You could log a bug/enhancement request to have AttributeOverride apply to inheritance as well, but still I'm not sure the updatable/insertable could be overridden.
You could try to fix up the descriptor in code using a DescriptorCustomizer. You could add a new mapping to the ClassDescriptor for the paisDespacho and mark it readOnly. You could also remove the ClassDescriptor's InheritancePolicy and map the inherited attributes as you wish.
James Sutherland EclipseLink, TopLink Wiki: EclipseLink, TopLink Forums: TopLink, EclipseLink Book: Java Persistence |
| Free embeddable forum powered by Nabble | Forum Help |