This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I want to save Customer entity in database (Derby):
I get reference to EntityManager and then I invoke:
However I get error:
Internal Exception: java.sql.SQLSyntaxErrorException: Table/view 'SEQUENCE' does not exist.
Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [2 parameters bound]
However SEQUENCE table is in my database. It was created automatically when I created tables from entities:
[EL Fine]: Connection(32280137)--CREATE TABLE CUSTOMER (ID BIGINT NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))
[EL Fine]: Connection(32280137)--CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))
[EL Fine]: Connection(32280137)--DELETE FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Fine]: Connection(32280137)--SELECT * FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Fine]: Connection(32280137)--INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values (SEQ_GEN, 0)
Using GenerationType.SEQUENCE means you wish the ID to be generated from a sequence which is held as a database object. I'm assuming you ate getting null because you haven't specified which sequence to use.