Edgar Hilton | 2013-09-24 09:07:13.0 | |
While attempting to fix code given to me by my customer, I created a simple test project that has three tables, I had my program create the tables (JPA 2.1 in NetBeans 7.3.1) in my persistence.xml file.
I have one table (ActivityLog) with an Id of type Long which has been annotated with "@GeneratedValue(strategy = GenerationType.AUTO)". So, if I type: EntityManager em = ... em.getTransaction().begin(); ActivityLog l = new ActivityLog(); l.setTimeStamp(new Date()); em.persist(l); <----------------- fails here What am I missing? Here is the exception: Exception [EclipseLink-4011] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException Exception Description: Error preallocating sequence numbers. The sequence table information is not complete. at org.eclipse.persistence.exceptions.DatabaseException.errorPreallocatingSequenceNumbers(DatabaseException.java:150) at org.eclipse.persistence.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:73) at org.eclipse.persistence.sequencing.DefaultSequence.getGeneratedVector(DefaultSequence.java:163) at org.eclipse.persistence.sequencing.Sequence.getGeneratedVector(Sequence.java:257) at org.eclipse.persistence.internal.sequencing.SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(SequencingManager.java:468) at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:1067) at org.eclipse.persistence.internal.sequencing.ClientSessionSequencing.getNextValue(ClientSessionSequencing.java:70) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:359) at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:318) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:484) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:4284) at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:518) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4229) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:496) | ||
HXTT Support | 2013-09-24 17:25:57.0 | |
Please enable automatic schema generation or create table for storing ID manually when using Table, Sequence or IDENTITY ID Generation.
opt#1. Enable automatic schema generation ... ... opt#2. Create table for storing ID manually Define Sequence in your entity @SequenceGenerator(name="Emp_Gen", sequenceName="Emp_Seq") @Id @GeneratedValue(generator="Emp_Gen") private int getId; SQL script to create sequence CREATE SEQUENCE Emp_Seq MINVALUE 1 START WITH 1 INCREMENT BY 1 | ||
Edgar Hilton | 2013-09-24 17:36:16.0 | |
Option 1 does not work. I have
set in my persistence.xml file. I still get the same exception. Trying option 2. | ||
Edgar Hilton | 2013-09-24 17:37:45.0 | |
I can now inform you that Option 2 did not work either. Same exception. | ||
Edgar Hilton | 2013-09-24 17:38:50.0 | |
Oops, my XML entry for Option 1 did not show up in my previous message. The actual element looks like this in my persistence.xml file:
property name="eclipselink.ddl-generation" value="drop-and-create-tables" | ||
HXTT Support | 2013-09-24 19:53:22.0 | |
Checked. Sorry. The pasted solution is wrong.
In fact, you need to download HXTT Glassfish Support Package, and add lt;property name="eclipselink.platform.class.name" value="com.hxtt.support.eclipselink.DbfPlatform" / gt; in your persistence.xml , then your issue will disappear. | ||
HXTT Support | 2013-09-24 20:34:58.0 | |
For the latest persistence.xml version, you can use eclipselink.target-database property to replace eclipselink.platform.class.name .
Passed test for the following parameters with the latest package: @GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.TABLE) |