admin管理员组文章数量:1025244
I am migrating xml configuration to annotations.
I have a class:
@Entity
@Table(name = "INSTRUMENT_OFFERINGS")
@Inheritance(strategy = InheritanceType.JOINED)
public class InstrumentOffering extends HibernatePersistentObject
implements Serializable, Comparable<InstrumentOffering>
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "instrument_offerings_sequence")
@SequenceGenerator(name = "instrument_offerings_sequence", sequenceName = "instrument_offerings_sequence")
@Column(name = "INSTRUMENT_OFFERINGS_ID")
private Integer instrumentOfferingId;
and second which is extending previous:
@Entity
@Table(name = "INSTRUMENT_OFFERINGS_HISTORY")
@PrimaryKeyJoinColumn(name = "INSTR_OFFERINGS_ID")
public class InstrumentOfferingHistory extends InstrumentOffering {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "instrument_history_seq")
@SequenceGenerator(name = "instrument_history_seq", sequenceName = "instrument_history_seq")
@Column(name = "INSTRUMENT_HISTORY_ID")
private Integer instrumentHistoryId;
I know that it's failing because I have two @Id
s. It's unbelivable that this construction was working in xml configuration but how should I handle it now?
InstrumentOfferingsId
is different than InstrumentOfferingsHistoryId
and can't be shared.
INSTRUMENT_OFFERINGS
has Id and INSTRUMENT_OFFERINGS_HISTORY
should has it's own Id. Plus INSTRUMENT_OFFERINGS_HISTORY
can have one INSTRUMENT_HISTORY_ID
but it's @ManyToOne
to INSTRUMENT_OFFERINGS
.
I should create third class without @Id
which both classes will extend and both will have their own @Id
? Is there different way?
I am migrating xml configuration to annotations.
I have a class:
@Entity
@Table(name = "INSTRUMENT_OFFERINGS")
@Inheritance(strategy = InheritanceType.JOINED)
public class InstrumentOffering extends HibernatePersistentObject
implements Serializable, Comparable<InstrumentOffering>
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "instrument_offerings_sequence")
@SequenceGenerator(name = "instrument_offerings_sequence", sequenceName = "instrument_offerings_sequence")
@Column(name = "INSTRUMENT_OFFERINGS_ID")
private Integer instrumentOfferingId;
and second which is extending previous:
@Entity
@Table(name = "INSTRUMENT_OFFERINGS_HISTORY")
@PrimaryKeyJoinColumn(name = "INSTR_OFFERINGS_ID")
public class InstrumentOfferingHistory extends InstrumentOffering {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "instrument_history_seq")
@SequenceGenerator(name = "instrument_history_seq", sequenceName = "instrument_history_seq")
@Column(name = "INSTRUMENT_HISTORY_ID")
private Integer instrumentHistoryId;
I know that it's failing because I have two @Id
s. It's unbelivable that this construction was working in xml configuration but how should I handle it now?
InstrumentOfferingsId
is different than InstrumentOfferingsHistoryId
and can't be shared.
INSTRUMENT_OFFERINGS
has Id and INSTRUMENT_OFFERINGS_HISTORY
should has it's own Id. Plus INSTRUMENT_OFFERINGS_HISTORY
can have one INSTRUMENT_HISTORY_ID
but it's @ManyToOne
to INSTRUMENT_OFFERINGS
.
I should create third class without @Id
which both classes will extend and both will have their own @Id
? Is there different way?
本文标签:
版权声明:本文标题:java - org.hibernate.mapping.JoinedSubclass cannot be cast to org.hibernate.mapping.RootClass, two @Id - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745611758a2159041.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论