使用继承类的JPA / Hibernate中的复合键 [英] Composite Key in JPA / Hibernate with inherited class
本文介绍了使用继承类的JPA / Hibernate中的复合键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面的类结构中定义了一个复合标识。不幸的是,我总是得到一个hibernate错误,抱怨找不到part2:
在实体MoreClass:part2中找不到@IdClass的属性
任何人都可以帮我解决问题吗? (或者至少将我指向一个有用的jpa / hibernate doc?)
@IdClass(ClassKey.class)
@Entity
public class MoreClass extends LessClass implements Serializable
{
@Id
String part1;
}
@MappedSuperclass
public class LessClass implements Serializable
{
@Id
String part2;
}
public class ClassKey implements Serializable
{
String part1;
String part2;
}
解决方案
c $ c>同样的问题。
@Override
@Id
public getPart2(){
return super.getPart2();
}
这似乎有效,我认为它是一个错误。请参阅 https://hibernate.atlassian.net/browse/HHH-9114 。
i have a composite id defined on my class structure as below. Unfortunatly i always get a hibernate error that complains on the not found "part2":
"Property of @IdClass not found in entity MoreClass : part2"
Can anybody help me on fixing the problem? (or at least point me on a helpful jpa/hibernate doc?)
@IdClass(ClassKey.class)
@Entity
public class MoreClass extends LessClass implements Serializable
{
@Id
String part1;
}
@MappedSuperclass
public class LessClass implements Serializable
{
@Id
String part2;
}
public class ClassKey implements Serializable
{
String part1;
String part2;
}
解决方案
Actually bumped into the same problem
.
As:
@Override
@Id
public getPart2() {
return super.getPart2();
}
Does seem to work, I would deem it a bug. See https://hibernate.atlassian.net/browse/HHH-9114.
这篇关于使用继承类的JPA / Hibernate中的复合键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文