0
@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

Community
  • 1
  • 1
muthukumar
  • 2,233
  • 3
  • 23
  • 30
  • 1
    I've no idea what is a "table with multiple Sequence"; you have an id field (of Whatever) that is a sequence, and you have a 1-1 relation. Post the generator definition for FooSequence. Post the "error" (and stack trace). – Neil Stockton Jul 31 '16 at 06:26
  • "Do we need to have a separate table". Separate table for what? Your entities have their own tables by definition ... "Emp" and "FooSequence". Read a basic JPA document and it tells you all about 1-1 relations – Neil Stockton Jul 31 '16 at 18:38
  • It was a defect in JPA and found a JIRA which was still open – muthukumar Aug 02 '16 at 18:59

0 Answers0