@Entity
public class FooSequence {
@Id
@SequenceGenerator(name="foo_seq_id", sequenceName="seq_id_K", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="foo_seq_id")
@Column(name = "E_I")
private Long value;
}
@Entity
@Table(name="Emp")
public class Whatever {
@Id
@SequenceGenerator(name="seq_id", sequenceName="seq_id", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_id")
private Long id;
@OneToOne
private FooSequnce fooSeq;
}
I have a table with mutliple Sequence where one column is a primary key and the other is an normal column and both not nullable field.
When I try to save the MyEntity table it is generating Sequence id for the FooSequence entity but it was trying to insert a row into the database for FooSequence and getting error.Do we need to have a seperate table in this case. Can't we achieve without the other new table for FooSequence. Sorce Link