JPA使用@AttributeOverride继承地图

时间:2015-03-13 09:23:59

标签: java jpa eclipselink

我正在使用eclipse链接2.5.2,我有以下继承结构:

@MappedSuperclass
public abstract class LocalizedEntity {

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


...

在扩展课程中,我试图改变&#34;值&#34;的长度。地图栏。

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

但是我收到了以下错误:

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

似乎eclipse链接试图仅通过“键”键进行导航。地图的一部分。事实上,关键是&#39;属于&#39; l10nValues&#39;是&#34; LocalizedField&#34;类型的对象。 值侧是一个简单的字符串:如何浏览值以更改其长度?

由于

LocalizedField类定义为@Embeddable。这个类定义了我的地图的关键部分,但我想访问值1。

@Embeddable
public final class LocalizedField implements Serializable{

1 个答案:

答案 0 :(得分:1)

答案是使用@AttributeOverride和&#34; value.l10nValues&#34;。出于某种原因,它适用于计票。