[英]Is there a change between Hibernate 4.3.x and 4.2.x in how they hydrate abstract implemented classes
We recently upgraded from Hibernate 4.2.12 to 4.3.5, and after we upgraded getting an abstract class started to fail with this error: 我们最近从Hibernate 4.2.12升级到4.3.5,并且在升级后,由于以下错误,抽象类开始失败:
Request processing failed; nested exception is javax.persistence.EntityNotFoundException: Unable to find com.siftit.domain.core.user.User with id 138
The user actually exists, and like I said this works in 4.2.12, but once we upgrade to 4.3.5 it fails, but if we change the user to be a specific type (ie SomeUser) then the get works. 用户实际上已经存在,并且就像我说的那样在4.2.12中有效,但是一旦我们升级到4.3.5,它就会失败,但是如果我们将用户更改为特定类型(即SomeUser),则get可以正常工作。
We are using: 我们正在使用:
Spring: 4.0.3.RELEASE 春季:4.0.3.RELEASE
Spring Data: 1.5.1.RELEASE 春季数据:1.5.1.RELEASE
JPA: 1.2 JPA:1.2
@MappedSuperclass
public class AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
protected Long id;
}
@Entity
@Table(name = "user")
@Inheritance(strategy= InheritanceType.JOINED)
public abstract class User extends AbstractEntity {
}
@Entity
@Table(name="someUser")
public class SomeUser extends User {
}
@Entity
@Table(name="someClass")
public class SomeClass extends AbstractEntity {
@ManyToOne
User user;
public User getUser(){ return user;} //This is really a restaurant user that should fill this and if we map it as a restaurant user, everything works, but if we keep it mapped as user it fails.
}
I bumped into the same problem while upgrading from 4.2.7 to 4.3.5. 从4.2.7升级到4.3.5时遇到了同样的问题。 Using
InheritanceType.SINGLE_TABLE
instead of InheritanceType.JOINED
fixed the problem for me. 使用
InheritanceType.SINGLE_TABLE
而不是InheritanceType.JOINED
为我解决了此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.