I have a simple entity class:
@Entity
public class Users implements Serializable {
@Id
@Column(name = "USER_ID", nullable = false)
@SequenceGenerator(name = "USER_ID_SEQ", sequenceName = "USER_ID_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USER_ID_SEQ")
private Long userId;
@Column(name = "USER_NAME", nullable = false, length = 20)
private String userName;
/* ... */
}
Asking for schema generation in persistence.xml:
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="javax.persistence.jtaDataSource" value="java:/app/jdbc/jdbc/Local_DB_User_GuyDS"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="both"/>
<property name="eclipselink.application-location" value="/home/guy/jdeveloper/mywork/guy/JavaPersistenceTest3/TopLinkTest/src/META-INF/"/>
<property name="eclipselink.target-database" value="Oracle11"/>
</properties>
The SQL generated looks ok:
CREATE TABLE USERS (USER_ID NUMBER(19) NOT NULL, USER_NAME VARCHAR2(20) NOT NULL, PRIMARY KEY (USER_ID))
CREATE SEQUENCE USER_ID_SEQ START WITH 1
But when executed, I get this:
<Mar 24, 2011 8:20:07 PM EDT> <Notice> <EclipseLink> <BEA-2005000> <2011-03-24 20:20:07.664--ServerSession(26549028)--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872>
<Mar 24, 2011 8:20:07 PM EDT> <Notice> <EclipseLink> <BEA-2005000> <2011-03-24 20:20:07.664--ServerSession(26549028)--Server: WebLogic Server 10.3.3.0 Fri Apr 9 00:05:28 PDT 2010 1321401 >
<Mar 24, 2011 8:20:07 PM EDT> <Notice> <EclipseLink> <BEA-2005000> <2011-03-24 20:20:07.666--ServerSession(26549028)--file:/home/guy/.jdeveloper/system11.1.1.3.37.56.60/o.j2ee/drs/JavaPersistenceTest3/TopLinkTestWebApp.war/WEB-INF/classes/_TopLinkTest login successful>
<Mar 24, 2011 8:20:07 PM EDT> <Warning> <EclipseLink> <BEA-2005000> <2011-03-24 20:20:07.722--ServerSession(26549028)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist
Error Code: 2289
Call: SELECT USER_ID_SEQ.NEXTVAL FROM DUAL
Query: ValueReadQuery(sql="SELECT USER_ID_SEQ.NEXTVAL FROM DUAL")>
Strangely, the code actually works despite the error message. The test code is minimal:
Users users = new Users();
users.setUserName(name);
em.persist(users);
... and the squence is created, and the table correctly inserts rows, with the right sequence numbers.
If I disable schema generation, then everything works normally with no error messages. Anyone know what is happening?
This is for Weblogic 10.3.3.0 on Linux.
Thanks.
-Guy