semantic-dev
semantic-dev

Reputation: 1123

JPA use @AttributeOverride for inherited map

I am using eclipse link 2.5.2 and I have the following inheritance structure:

@MappedSuperclass
public abstract class LocalizedEntity {

/**
 * {@link Map} containing the String localized values.
 */
@ElementCollection    
protected Map<LocalizedField, String> l10nValues = new HashMap<LocalizedField, String>();


...

In the extended class I am trying to change the length for the "value" column of the map.

@AttributeOverride(name="l10nValues.value", column=@Column(length=2048))   
public class MyClass extends LocalizedEntity

But I got the following error:

Internal Exception: Exception [EclipseLink-7200] (Eclipse Persistence  Services - 2.5.2.v20131113-a7346c6):   org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute [value] was not found on the embeddable    class [class com.thedigitalstack.model.l10n.LocalizedField]. It is  referenced in an attribute override for the embedded attribute [l10nValues] on class [class com.finantix.agent.core.SectionContent].
 javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20131113-a7346c6): org.eclipse.persistence.exceptions.EntityManagerSetupException
 Exception Description: Predeployment of PersistenceUnit [com.finantix.agent.core.model@HK] failed.
 Internal Exception: Exception [EclipseLink-7200] (Eclipse Persistence Services - 2.5.2.v20131113-a7346c6): org.eclipse.persistence.exceptions.ValidationException

It seems that eclipse link tries to navigate only trough the 'key' part of the map. In fact the 'key' is of 'l10nValues' is an object of type "LocalizedField". The value side is a simple String: how to navigate through the value in order to change its length ?

Thanks

LocalizedField class is defined as @Embeddable. This class defines the key part of my map but I want to access to the value one.

@Embeddable
public final class LocalizedField implements Serializable{

Upvotes: 0

Views: 320

Answers (1)

semantic-dev
semantic-dev

Reputation: 1123

The answer is using @AttributeOverride with "value.l10nValues". For some reason it works on the countrary.

Upvotes: 1

Related Questions