2
을 상속 저장할 수 없습니다 - 슈퍼 클래스와 그 자식 :Hibernate는 내가 두 개체가 개체
슈퍼 클래스 (그러나 초록) :
@Entity
@Table(name="table1")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class table1 implements Serializable {
@Id
String id;
}
서브 클래스 :
@Entity
@Table(name="table2")
public class table2 extends table1 {
String somefield;
}
두 테이블이 잘 생성 시작하는 동안.
하지만 서브 클래스의 객체 저장하려고 할 때 : org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session
방법이 문제를 해결하기 위해 : 나는 오류가
table2 obj = new table2();
dbSession.save(obj);
를? 나는 처음부터 두 번째 클래스를 확장하고 이것을 다른 테이블로 사용하기 만하면된다.
나는 또한 .merge()
메서드를 시도했지만 여전히 작동하지 않습니다.
작동, 감사합니다! – WildDev