JPA and Address Book Demo

I’m pretty new in JPA and Vaadin.
I tried to implement “Adding JPA based persistence to the Address Book Demo” by Kim using Mysql and rised the following error:

SEVERE: Exception sending context initialized event to listener instance of class YourApplicationContextListener
Local Exception Stack:
Exception [EclipseLink-4002]
(Eclipse Persistence Services - 1.1.4.v20100812-r7860): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘acesso.sequence’ doesn’t exist
Error Code: 1146
Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN]

Query: DataModifyQuery(sql=“UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?”)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:323)

I would be grateful for one help!!!

It looks like your database structure hasn’t been correctly set up. In your persistence.xml file, make sure your persistence unit has this line

<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />

drop-and-create-tables means that when your facade is registered, the persistence unit will drop all tables from your database and then recreate them. You probably don’t want to recreate the database everytime you start the server, so after the first time you can change the property’s value to “none”.

If this wasn’t the problem, let me know and I’ll try to figure out what else the problem could be :slight_smile:

I think that your solution is exactly what i needed.

When i was trying to solve i did it :

CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50), SEQ_COUNT DECIMAL(15));
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values (‘SEQ_GEN’, 0)

And all works.

Thanks for your help!

Thank you Kim Leppänen