Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problems with auto-generated sequence
icon5.gif  Problems with auto-generated sequence [message #508320] Mon, 18 January 2010 12:29 Go to next message
Dominic Caudell is currently offline Dominic CaudellFriend
Messages: 4
Registered: January 2010
Junior Member
I'm new to EclipseLink and I'm having trouble using sequence generators with automatic database creation.
EclipseLink appears to be creating the required sequence generator, but apparently only after it needs it, and is tossing an SQL error as a result.

Does anyone have any insight as to what I might be doing wrong? Any help would be greatly appreciated.

I've created an entity bean with a field as follows:
@Id    
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="dbfile_fileid_seq")
@SequenceGenerator(name="dbfile_fileid_seq", allocationSize=1)
@Column(name = "fileid", nullable = false)
private BigInteger fileid;


I'm using a fairly empty persistence.xml and relying on auto-discovery of persistent classes. I'm also specifying PU properties at runtime. In particular I'm specifying the properties:
properties.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION);


The error I'm seeing is as follows:
[EL Info]: 2010-01-18 06:39:55.734--ServerSession(17674230)--file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser login successful
[EL Warning]: 2010-01-18 06:39:56.859--ServerSession(17674230)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: relation "dbfile_fileid_seq" does not exist
Error Code: 0
Call: select nextval('dbfile_fileid_seq')
Query: ValueReadQuery(sql="select nextval('dbfile_fileid_seq')")


However, when I examine the database, the sequence "dbfile_fileid_seq" exists, and the query completes successfully.

I'm running postgres in a plain-old java application.
Re: Problems with auto-generated sequence [message #508369 is a reply to message #508320] Mon, 18 January 2010 15:10 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Turn logging on FINEST and check what DDL is generated at startup, it seems like it may not be occurring.

Please include your persistence.xml and how you are creating your EntityManagerFactory.


James : Wiki : Book : Blog : Twitter
Re: Problems with auto-generated sequence [message #508451 is a reply to message #508369] Mon, 18 January 2010 22:04 Go to previous messageGo to next message
Dominic Caudell is currently offline Dominic CaudellFriend
Messages: 4
Registered: January 2010
Junior Member
Yup. From the logs it looks like EclipseLink is dropping the sequence, selecting from it, and then creating it. What would cause it to do that?

Here's the information you asked for.

Here's persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>     
      <jar-file>com.xtrafe.vyper2-ejb.jar</jar-file>      
      <exclude-unlisted-classes>false</exclude-unlisted-classes>
      <properties>
      </properties>
    </persistence-unit>
</persistence>


This is the complete set of properties going into the EntityManagerFactory:
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.adviseConstructorPre(): Advising: com.xtrafe.vyper2.ejb.DBFileSystemEJBImpl@61c596
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'javax.persistence.jdbc.url' value = 'jdbc:postgresql:probedb'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'javax.persistence.transactionType' value = 'RESOURCE_LOCAL'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'eclipselink.ddl-generation.output-mode' value = 'database'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'javax.persistence.jdbc.password' value = 'probeuserpw'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'eclipselink.logging.level' value = 'FINEST'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'eclipselink.ddl-generation' value = 'drop-and-create-tables'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'javax.persistence.jdbc.driver' value = 'org.postgresql.Driver'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'eclipselink.target-server' value = 'None'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'javax.persistence.jdbc.user' value = 'probeuser'
Mon Jan 18 16:05:48 GMT 2010 > com.xtrafe.vyper2.ejb.EJBContainer.getEntityManager(): PU Property: K = 'eclipselink.persistenceunits' value = 'default'


This is the EclipseLink log output:
[EL Finest]: 2010-01-18 16:05:53.218--ServerSession(6995211)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit default; session file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser; state Initial; factoryCount 0
[EL Finest]: 2010-01-18 16:05:53.515--ServerSession(6995211)--Thread(Thread[main,5,main])--property=javax.persistence.transactionType; value=RESOURCE_LOCAL
[EL Finest]: 2010-01-18 16:05:53.515--ServerSession(6995211)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finer]: 2010-01-18 16:05:54.14--ServerSession(6995211)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-ejb.jar
[EL Finer]: 2010-01-18 16:05:54.156--ServerSession(6995211)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar
[EL Finer]: 2010-01-18 16:05:54.156--ServerSession(6995211)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-ejb.jar
[EL Finer]: 2010-01-18 16:05:54.156--ServerSession(6995211)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar
[EL Config]: 2010-01-18 16:05:57.765--ServerSession(6995211)--Thread(Thread[main,5,main])--The access type for the persistent class [class com.xtrafe.vyper2.ejb.entity.Dbfile] is set to [FIELD].
[EL Config]: 2010-01-18 16:05:58.718--ServerSession(6995211)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xtrafe.vyper2.ejb.entity.Dbfile] is being defaulted to: Dbfile.
[EL Finest]: 2010-01-18 16:05:59.078--ServerSession(6995211)--Thread(Thread[main,5,main])--End predeploying Persistence Unit default; session file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser; state Predeployed; factoryCount 0
[EL Finer]: 2010-01-18 16:05:59.078--Thread(Thread[main,5,main])--JavaSECMPInitializer - transformer is null.
[EL Finest]: 2010-01-18 16:05:59.078--ServerSession(6995211)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit default; session file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser; state Predeployed; factoryCount 0
[EL Finest]: 2010-01-18 16:05:59.078--ServerSession(6995211)--Thread(Thread[main,5,main])--End predeploying Persistence Unit default; session file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser; state Predeployed; factoryCount 1
[EL Finest]: 2010-01-18 16:05:59.125--ServerSession(6995211)--Thread(Thread[main,5,main])--Begin deploying Persistence Unit default; session file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser; state Predeployed; factoryCount 1
[EL Finer]: 2010-01-18 16:05:59.296--ServerSession(6995211)--Thread(Thread[main,5,main])--Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax/validation/Validation
[EL Finest]: 2010-01-18 16:05:59.359--ServerSession(6995211)--Thread(Thread[main,5,main])--property=eclipselink.target-server; value=None; translated value=org.eclipse.persistence.platform.server.NoServerPlatform
[EL Finest]: 2010-01-18 16:05:59.375--ServerSession(6995211)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST
[EL Finest]: 2010-01-18 16:05:59.375--ServerSession(6995211)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST
[EL Finest]: 2010-01-18 16:05:59.375--ServerSession(6995211)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.user; value=probeuser
[EL Finest]: 2010-01-18 16:05:59.375--ServerSession(6995211)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.password; value=xxxxxx
[EL Finest]: 2010-01-18 16:06:01.468--ServerSession(6995211)--Thread(Thread[main,5,main])--property=javax.persistence.transactionType; value=RESOURCE_LOCAL
[EL Finest]: 2010-01-18 16:06:01.468--ServerSession(6995211)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.driver; value=org.postgresql.Driver
[EL Finest]: 2010-01-18 16:06:01.468--ServerSession(6995211)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.url; value=jdbc:postgresql:probedb
[EL Info]: 2010-01-18 16:06:01.468--ServerSession(6995211)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20091127-r5931
******Called with request 'META-INF/services/java.sql.Driver'
******Called with request 'org/postgresql/driverconfig.properties'
[EL Finest]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.HSQLPlatform, RegularExpression: (?i)hsql.*.
[EL Finest]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.InformixPlatform, RegularExpression: (?i)informix.*.
[EL Finest]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.PointBasePlatform, RegularExpression: (?i)pointbase.*.
[EL Finest]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.DB2Platform, RegularExpression: (?i).*db2.*.
[EL Finest]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.SQLServerPlatform, RegularExpression: (?i)microsoft.*.
[EL Finest]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.PostgreSQLPlatform, RegularExpression: (?i)postgresql.*.
[EL Fine]: 2010-01-18 16:06:02.64--Thread(Thread[main,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.PostgreSQLPlatform
[EL Config]: 2010-01-18 16:06:03.031--ServerSession(6995211)--Connection(8894235)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
        platform=>PostgreSQLPlatform
        user name=> "probeuser"
        datasource URL=> "jdbc:postgresql:probedb"
))
[EL Config]: 2010-01-18 16:06:03.062--ServerSession(6995211)--Connection(5465344)--Thread(Thread[main,5,main])--Connected: jdbc:postgresql:probedb
        User: probeuser
        Database: PostgreSQL  Version: 8.2.4
        Driver: PostgreSQL Native Driver  Version: PostgreSQL 8.2 JDBC4 with SSL (build 505)
[EL Config]: 2010-01-18 16:06:03.062--ServerSession(6995211)--Connection(17563357)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
        platform=>PostgreSQLPlatform
        user name=> "probeuser"
        datasource URL=> "jdbc:postgresql:probedb"
))
[EL Config]: 2010-01-18 16:06:03.093--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--Connected: jdbc:postgresql:probedb
        User: probeuser
        Database: PostgreSQL  Version: 8.2.4
        Driver: PostgreSQL Native Driver  Version: PostgreSQL 8.2 JDBC4 with SSL (build 505)
[EL Finest]: 2010-01-18 16:06:03.218--ServerSession(6995211)--Thread(Thread[main,5,main])--sequencing connected, state is Preallocation_NoTransaction_State
[EL Finest]: 2010-01-18 16:06:03.218--ServerSession(6995211)--Thread(Thread[main,5,main])--sequence dbfile_fileid_seq: preallocation size 1
[EL Info]: 2010-01-18 16:06:07.015--ServerSession(6995211)--Thread(Thread[main,5,main])--file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser login successful
[EL Finest]: 2010-01-18 16:06:07.515--ServerSession(6995211)--Thread(Thread[main,5,main])--Execute query DataModifyQuery(sql="DROP TABLE dbfile")
[EL Fine]: 2010-01-18 16:06:07.531--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--DROP TABLE dbfile
[EL Finest]: 2010-01-18 16:06:07.796--ServerSession(6995211)--Thread(Thread[main,5,main])--Execute query DataModifyQuery(sql="CREATE TABLE dbfile (fileid BIGINT NOT NULL, filedata BYTEA, filepath VARCHAR(255), addeddate TIMESTAMP NOT NULL, modifieddate TIMESTAMP, filename VARCHAR(255) NOT NULL, isdirectory BOOLEAN NOT NULL, filetype VARCHAR(255), parentid BIGINT, PRIMARY KEY (fileid))")
[EL Fine]: 2010-01-18 16:06:07.796--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--CREATE TABLE dbfile (fileid BIGINT NOT NULL, filedata BYTEA, filepath VARCHAR(255), addeddate TIMESTAMP NOT NULL, modifieddate TIMESTAMP, filename VARCHAR(255) NOT NULL, isdirectory BOOLEAN NOT NULL, filetype VARCHAR(255), parentid BIGINT, PRIMARY KEY (fileid))
[EL Finest]: 2010-01-18 16:06:07.843--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--CREATE TABLE / PRIMARY KEY will create implicit index "dbfile_pkey" for table "dbfile":00000 - null
[EL Finest]: 2010-01-18 16:06:07.859--ServerSession(6995211)--Thread(Thread[main,5,main])--Execute query DataModifyQuery(sql="DROP SEQUENCE dbfile_fileid_seq")
[EL Fine]: 2010-01-18 16:06:07.859--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--DROP SEQUENCE dbfile_fileid_seq
[EL Finest]: 2010-01-18 16:06:07.859--ServerSession(6995211)--Thread(Thread[main,5,main])--Execute query ValueReadQuery(sql="select nextval('dbfile_fileid_seq')")
[EL Fine]: 2010-01-18 16:06:07.859--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--select nextval(dbfile_fileid_seq)
[EL Fine]: 2010-01-18 16:06:07.875--ServerSession(6995211)--Thread(Thread[main,5,main])--SELECT 1
[EL Warning]: 2010-01-18 16:06:08.312--ServerSession(6995211)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: relation "dbfile_fileid_seq" does not exist
Error Code: 0
Call: select nextval('dbfile_fileid_seq')
Query: ValueReadQuery(sql="select nextval('dbfile_fileid_seq')")
[EL Finest]: 2010-01-18 16:06:08.328--ServerSession(6995211)--Thread(Thread[main,5,main])--Execute query DataModifyQuery(sql="CREATE SEQUENCE dbfile_fileid_seq START WITH 1")
[EL Fine]: 2010-01-18 16:06:08.328--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--CREATE SEQUENCE dbfile_fileid_seq START WITH 1
[EL Finer]: 2010-01-18 16:06:08.625--ServerSession(6995211)--Thread(Thread[main,5,main])--No Canonical Metamodel classes found during initialization.
[EL Finest]: 2010-01-18 16:06:08.625--ServerSession(6995211)--Thread(Thread[main,5,main])--End deploying Persistence Unit default; session file:/D:/Dev/Projects/com.xtrafe.probe/dist/lib/com.xtrafe.vyper2-vds.jar_default_transactionType=RESOURCE_LOCAL_url=jdbc:postgresql:probedb_user=probeuser; state Deployed; factoryCount 1
[EL Finer]: 2010-01-18 16:06:09.062--ServerSession(6995211)--Thread(Thread[main,5,main])--client acquired
[EL Finest]: 2010-01-18 16:06:09.421--UnitOfWork(1701135)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Dbfile sql="SELECT fileid, filedata, filepath, addeddate, modifieddate, filename, isdirectory, filetype, parentid FROM dbfile WHERE (fileid = ?)")
[EL Fine]: 2010-01-18 16:06:09.453--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--SELECT fileid, filedata, filepath, addeddate, modifieddate, filename, isdirectory, filetype, parentid FROM dbfile WHERE (fileid = ?)
        bind => [0]
[EL Finest]: 2010-01-18 16:06:09.5--UnitOfWork(1701135)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Dbfile sql="SELECT fileid, filedata, filepath, addeddate, modifieddate, filename, isdirectory, filetype, parentid FROM dbfile WHERE (fileid = ?)")
[EL Fine]: 2010-01-18 16:06:09.5--ServerSession(6995211)--Connection(9006608)--Thread(Thread[main,5,main])--SELECT fileid, filedata, filepath, addeddate, modifieddate, filename, isdirectory, filetype, parentid FROM dbfile WHERE (fileid = ?)
        bind => [0]

(Stuff with **** in front is the classloader saying it had a 'getResources' call.)

Re: Problems with auto-generated sequence [message #508842 is a reply to message #508320] Wed, 20 January 2010 14:23 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

the "dbfile_fileid_seq" does not exist" message you see in the logs is not an exception that is thrown. It is just a message printed at the warning level to indicate that the sequence does not exist - a result of the drop and create DDL. The next statement in the logs indicates the sequence is being created, so the application should be working fine.

Best Regards,
Chris
Previous Topic:Schema name from orm.xml
Next Topic:Best way for Entities
Goto Forum:
  


Current Time: Tue Apr 16 09:22:59 GMT 2024

Powered by FUDForum. Page generated in 0.79618 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top