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?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745611759a4635986.html
评论列表(0条)