gpt4 book ai didi

java - JPA使用@AttributeOverride来继承映射

转载 作者:行者123 更新时间:2023-12-01 11:47:40 31 4
gpt4 key购买 nike

我使用的是 eclipse link 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>();


...

在扩展类中,我试图更改 map “值”列的长度。

@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 链接尝试仅通过 map 的“关键”部分进行导航。事实上,“l10nValues”的“key”是“LocalizedField”类型的对象。值一侧是一个简单的字符串:如何浏览值以更改其长度?

谢谢

LocalizedField 类定义为@Embeddable。此类定义了我的 map 的关键部分,但我想访问值之一。

@Embeddable
public final class LocalizedField implements Serializable{

最佳答案

答案是使用 @AttributeOverride 和“value.l10nValues”。由于某种原因,它在该国有效。

关于java - JPA使用@AttributeOverride来继承映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29028681/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com