diff --git a/examples/database-mysql/src/main/java/io/quarkus/qe/database/mysql/Book.java b/examples/database-mysql/src/main/java/io/quarkus/qe/database/mysql/Book.java index d89f5e476..31b957e5c 100644 --- a/examples/database-mysql/src/main/java/io/quarkus/qe/database/mysql/Book.java +++ b/examples/database-mysql/src/main/java/io/quarkus/qe/database/mysql/Book.java @@ -1,14 +1,22 @@ package io.quarkus.qe.database.mysql; import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.validation.constraints.NotBlank; -import io.quarkus.hibernate.orm.panache.PanacheEntity; +import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @Entity @Table(name = "book") -public class Book extends PanacheEntity { +public class Book extends PanacheEntityBase { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + public Long id; + @NotBlank(message = "book title must be set") public String title; diff --git a/examples/database-mysql/src/main/resources/import.sql b/examples/database-mysql/src/main/resources/import.sql index df71bf7ae..6ee63a824 100644 --- a/examples/database-mysql/src/main/resources/import.sql +++ b/examples/database-mysql/src/main/resources/import.sql @@ -1,8 +1,7 @@ -INSERT INTO book (id, title, author) VALUES (1, 'Foundation', 'Isaac Asimov'); -INSERT INTO book (id, title, author) VALUES (2, '2001: A Space Odyssey', 'Arthur C. Clarke'); -INSERT INTO book (id, title, author) VALUES (3, 'Stranger in a Strange Land', 'Robert A. Heinlein'); -INSERT INTO book (id, title, author) VALUES (4, 'Ender''s Game', 'Orson Scott Card'); -INSERT INTO book (id, title, author) VALUES (5, 'Hyperion', 'Dan Simmons'); -INSERT INTO book (id, title, author) VALUES (6, 'Anathem', 'Neal Stephenson'); -INSERT INTO book (id, title, author) VALUES (7, 'Perdido Street Station', 'China Miéville'); -UPDATE hibernate_sequence SET next_val = 8; \ No newline at end of file +INSERT INTO book (title, author) VALUES ('Foundation', 'Isaac Asimov'); +INSERT INTO book (title, author) VALUES ('2001: A Space Odyssey', 'Arthur C. Clarke'); +INSERT INTO book (title, author) VALUES ('Stranger in a Strange Land', 'Robert A. Heinlein'); +INSERT INTO book (title, author) VALUES ('Ender''s Game', 'Orson Scott Card'); +INSERT INTO book (title, author) VALUES ('Hyperion', 'Dan Simmons'); +INSERT INTO book (title, author) VALUES ('Anathem', 'Neal Stephenson'); +INSERT INTO book (title, author) VALUES ('Perdido Street Station', 'China Miéville'); \ No newline at end of file diff --git a/examples/database-mysql/src/test/resources/import-in-test.sql b/examples/database-mysql/src/test/resources/import-in-test.sql index df71bf7ae..6ee63a824 100644 --- a/examples/database-mysql/src/test/resources/import-in-test.sql +++ b/examples/database-mysql/src/test/resources/import-in-test.sql @@ -1,8 +1,7 @@ -INSERT INTO book (id, title, author) VALUES (1, 'Foundation', 'Isaac Asimov'); -INSERT INTO book (id, title, author) VALUES (2, '2001: A Space Odyssey', 'Arthur C. Clarke'); -INSERT INTO book (id, title, author) VALUES (3, 'Stranger in a Strange Land', 'Robert A. Heinlein'); -INSERT INTO book (id, title, author) VALUES (4, 'Ender''s Game', 'Orson Scott Card'); -INSERT INTO book (id, title, author) VALUES (5, 'Hyperion', 'Dan Simmons'); -INSERT INTO book (id, title, author) VALUES (6, 'Anathem', 'Neal Stephenson'); -INSERT INTO book (id, title, author) VALUES (7, 'Perdido Street Station', 'China Miéville'); -UPDATE hibernate_sequence SET next_val = 8; \ No newline at end of file +INSERT INTO book (title, author) VALUES ('Foundation', 'Isaac Asimov'); +INSERT INTO book (title, author) VALUES ('2001: A Space Odyssey', 'Arthur C. Clarke'); +INSERT INTO book (title, author) VALUES ('Stranger in a Strange Land', 'Robert A. Heinlein'); +INSERT INTO book (title, author) VALUES ('Ender''s Game', 'Orson Scott Card'); +INSERT INTO book (title, author) VALUES ('Hyperion', 'Dan Simmons'); +INSERT INTO book (title, author) VALUES ('Anathem', 'Neal Stephenson'); +INSERT INTO book (title, author) VALUES ('Perdido Street Station', 'China Miéville'); \ No newline at end of file diff --git a/examples/database-oracle/src/main/java/io/quarkus/qe/database/oracle/Book.java b/examples/database-oracle/src/main/java/io/quarkus/qe/database/oracle/Book.java index 8724ffd5e..d39370939 100644 --- a/examples/database-oracle/src/main/java/io/quarkus/qe/database/oracle/Book.java +++ b/examples/database-oracle/src/main/java/io/quarkus/qe/database/oracle/Book.java @@ -1,14 +1,24 @@ package io.quarkus.qe.database.oracle; import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.SequenceGenerator; import jakarta.persistence.Table; import jakarta.validation.constraints.NotBlank; -import io.quarkus.hibernate.orm.panache.PanacheEntity; +import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @Entity @Table(name = "book") -public class Book extends PanacheEntity { +public class Book extends PanacheEntityBase { + + @Id + @SequenceGenerator(name = "bookSequence", sequenceName = "Book_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bookSequence") + public Long id; + @NotBlank(message = "book title must be set") public String title; diff --git a/examples/database-oracle/src/main/resources/import.sql b/examples/database-oracle/src/main/resources/import.sql index 3e89f794e..d3c025c7f 100644 --- a/examples/database-oracle/src/main/resources/import.sql +++ b/examples/database-oracle/src/main/resources/import.sql @@ -1,7 +1,7 @@ -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Foundation', 'Isaac Asimov'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, '2001: A Space Odyssey', 'Arthur C. Clarke'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Stranger in a Strange Land', 'Robert A. Heinlein'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Ender''s Game', 'Orson Scott Card'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Hyperion', 'Dan Simmons'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Anathem', 'Neal Stephenson'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Perdido Street Station', 'China Miéville'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Foundation', 'Isaac Asimov'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, '2001: A Space Odyssey', 'Arthur C. Clarke'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Stranger in a Strange Land', 'Robert A. Heinlein'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Ender''s Game', 'Orson Scott Card'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Hyperion', 'Dan Simmons'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Anathem', 'Neal Stephenson'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Perdido Street Station', 'China Miéville'); diff --git a/examples/database-oracle/src/test/resources/import-in-test.sql b/examples/database-oracle/src/test/resources/import-in-test.sql index 3e89f794e..d3c025c7f 100644 --- a/examples/database-oracle/src/test/resources/import-in-test.sql +++ b/examples/database-oracle/src/test/resources/import-in-test.sql @@ -1,7 +1,7 @@ -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Foundation', 'Isaac Asimov'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, '2001: A Space Odyssey', 'Arthur C. Clarke'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Stranger in a Strange Land', 'Robert A. Heinlein'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Ender''s Game', 'Orson Scott Card'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Hyperion', 'Dan Simmons'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Anathem', 'Neal Stephenson'); -INSERT INTO book (id, title, author) VALUES (hibernate_sequence.NEXTVAL, 'Perdido Street Station', 'China Miéville'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Foundation', 'Isaac Asimov'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, '2001: A Space Odyssey', 'Arthur C. Clarke'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Stranger in a Strange Land', 'Robert A. Heinlein'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Ender''s Game', 'Orson Scott Card'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Hyperion', 'Dan Simmons'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Anathem', 'Neal Stephenson'); +INSERT INTO book (id, title, author) VALUES (Book_SEQ.NEXTVAL, 'Perdido Street Station', 'China Miéville'); diff --git a/examples/database-postgresql/src/main/java/io/quarkus/qe/database/postgresql/Book.java b/examples/database-postgresql/src/main/java/io/quarkus/qe/database/postgresql/Book.java index edc4d3f4a..cbce8baa6 100644 --- a/examples/database-postgresql/src/main/java/io/quarkus/qe/database/postgresql/Book.java +++ b/examples/database-postgresql/src/main/java/io/quarkus/qe/database/postgresql/Book.java @@ -1,14 +1,24 @@ package io.quarkus.qe.database.postgresql; import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.SequenceGenerator; import jakarta.persistence.Table; import jakarta.validation.constraints.NotBlank; -import io.quarkus.hibernate.orm.panache.PanacheEntity; +import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @Entity @Table(name = "book") -public class Book extends PanacheEntity { +public class Book extends PanacheEntityBase { + + @Id + @SequenceGenerator(name = "bookSequence", sequenceName = "Book_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bookSequence") + public Long id; + @NotBlank(message = "book title must be set") public String title; diff --git a/examples/database-postgresql/src/main/resources/import.sql b/examples/database-postgresql/src/main/resources/import.sql index 90e60a6d2..7e1a1956d 100644 --- a/examples/database-postgresql/src/main/resources/import.sql +++ b/examples/database-postgresql/src/main/resources/import.sql @@ -1,7 +1,7 @@ -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Foundation', 'Isaac Asimov'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), '2001: A Space Odyssey', 'Arthur C. Clarke'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Stranger in a Strange Land', 'Robert A. Heinlein'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Ender''s Game', 'Orson Scott Card'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Hyperion', 'Dan Simmons'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Anathem', 'Neal Stephenson'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Perdido Street Station', 'China Miéville'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Foundation', 'Isaac Asimov'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), '2001: A Space Odyssey', 'Arthur C. Clarke'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Stranger in a Strange Land', 'Robert A. Heinlein'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Ender''s Game', 'Orson Scott Card'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Hyperion', 'Dan Simmons'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Anathem', 'Neal Stephenson'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Perdido Street Station', 'China Miéville'); diff --git a/examples/database-postgresql/src/test/resources/import-in-test.sql b/examples/database-postgresql/src/test/resources/import-in-test.sql index 90e60a6d2..7e1a1956d 100644 --- a/examples/database-postgresql/src/test/resources/import-in-test.sql +++ b/examples/database-postgresql/src/test/resources/import-in-test.sql @@ -1,7 +1,7 @@ -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Foundation', 'Isaac Asimov'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), '2001: A Space Odyssey', 'Arthur C. Clarke'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Stranger in a Strange Land', 'Robert A. Heinlein'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Ender''s Game', 'Orson Scott Card'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Hyperion', 'Dan Simmons'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Anathem', 'Neal Stephenson'); -INSERT INTO book (id, title, author) VALUES (nextval('hibernate_sequence'), 'Perdido Street Station', 'China Miéville'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Foundation', 'Isaac Asimov'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), '2001: A Space Odyssey', 'Arthur C. Clarke'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Stranger in a Strange Land', 'Robert A. Heinlein'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Ender''s Game', 'Orson Scott Card'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Hyperion', 'Dan Simmons'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Anathem', 'Neal Stephenson'); +INSERT INTO book (id, title, author) VALUES (nextval('Book_SEQ'), 'Perdido Street Station', 'China Miéville');