Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] JPA: Override a property attribute in a subclass

The 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.



xcallejas wrote:
> 
> Hi,
> 
> 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.
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/JPA%3A-Override-a-property-attribute-in-a-subclass-tp24975448p25062644.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top