diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java index 9ddcfd3..d3b2537 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java @@ -13,6 +13,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.validation.constraints.DecimalMax; import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Digits; @@ -65,7 +66,12 @@ public class Book { @Id @GeneratedValue( - strategy = GenerationType.AUTO + strategy = GenerationType.AUTO, + generator = "bookIdGenerator" + ) + @SequenceGenerator( + name = "bookIdGenerator", + sequenceName = "bookIdSequence" ) private long id; diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java index f520feb..fe3aa53 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java @@ -9,6 +9,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; @Entity public class Category { @@ -17,7 +18,12 @@ public class Category { // Primary key value in database @Id @GeneratedValue( - strategy = GenerationType.AUTO + strategy = GenerationType.AUTO, + generator = "categoryIdGenerator" + ) + @SequenceGenerator( + name = "categoryIdGenerator", + sequenceName = "categoryIdSequence" ) private long id;