wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes JPA - How to persist new table without exception (SE) environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA - How to persist new table without exception (SE) environment" Watch "JPA - How to persist new table without exception (SE) environment" New topic
Author

JPA - How to persist new table without exception (SE) environment

Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi All,

I got the following database exception when carrying out JPA persisting (JDK SE) record to STUDENT table which does not exist in the first place:

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown table 'student'
Error Code: 1051

Below are the tutorial codes that generates the record in STUDENT:



Table STUDENT did get generated despite the above exception. However, this exception will no longer show up for any additional persistences once STUDENT has been generated. The question is how to / what needs to be done to create automatically generate this table quitely in an empty database without getting the above exception?

I am running JDK1.6.0_17, Netbeans 6.9.1, GF3.1, MySQL 5.1 on Windows 7.

Thanks,

Jack
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Generating tables for a persistence unit is not standardized in JPA, so is provider specific.

For EclipseLink, you can enable table generation using the persistence.xml property,
<property name="eclipselink.ddl-generation" value="create-tables"/>

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/DDL

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Yes, you are right James,

Thanks again,

Jack
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA - How to persist new table without exception (SE) environment
 
Similar Threads
persistence.xml file for MS SQL Server 2000
javax.persistence.PersistenceException
Serious error in JPA with @Version
assertion error when unittesting persisting objects
Query after JPA collective update not getting updates