• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

JPA EclipseLink SEQUENCE table does not exist

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to save Customer entity in database (Derby):


I get reference to EntityManager and then I invoke:
manager.persist(new Customer());

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)


I do not have any idea. I want to cry (((.
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you ran the schema generation once before running the actual code (link)?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem actually was with that I searched wrong database. I did not specify: <jta-data-source>...</jta-data-source> element in persistence.xml and default database was chosen.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lucas

When you say the default database, what do you mean?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean that 'sun-appserv-samples' was chosen. I use Eclipse with Glassfish and Derby. That database was created automatically.

Can someone give me a clue why:

@GeneratedValue(strategy=GenerationType.AUTO)

works flawlessly whereas:

@GeneratedValue(strategy=GenerationType.SEQUENCE)

does not work. It gives exception that ID cannot have NULL value.

 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I have solved the problem.

After changing GenerationType in the entity it is necessary to regenerate tables. I use JPA Tools -> Generate tables from entities... from the context menu of JPA Project.

Can someone tell me what is the purpose of <property name="eclipselink.ddl-generation" value="none"/> element in persistence.xml?

By the way:
* adding <property name="eclipselink.logging.level" value="FINE"/> to persistence.xml is very useful while resolving strange issues like "JPA EclipseLink SEQUENCE table does not exist".
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that eclipselink.ddl-generation is similar to Hibernate's hbm2ddl.auto property. It basically allows you to configure how eclipselink manages your database schema.

For example, if you wanted eclipselink to create the database schema, you would use:

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, but when such creation occurs? During deployment?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic