Reputation: 13
I have created a simple JAVA app to learn database connection.
I have table USR_BOOKS in Oracle 11g database. Using EclipseLink(JPA 2.0) Persistence libray.
Using "Create Entity From Database", I created a class in Java, and created JPA Controller class.
Everything seems to work fine except that I always get
[EL Warning]: 2012-10-30 16:50:31.957--ServerSession(1278203495)--Exception
[EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by an existing object
Error Code: 955
Call: CREATE TABLE USR_BOOKS (ID NUMBER(19) NOT NULL, NAZOV VARCHAR2(255) NULL, PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE USR_BOOKS (ID NUMBER(19) NOT NULL, NAZOV VARCHAR2(255) NULL, PRIMARY KEY (ID))")
I am not calling the CREATE TABLE query anywhere, but until I call function
EntityManager em = emf.createEntityManager();
the error is not there It looks like that the function createEntityManager() creates the SQL statement and sends it into database.
I tried deleting the table from database. Then the program creates the table USR_BOOKS in database - again, I am NOT accidentally calling any function that could cause it.
This is basically my code:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JavaOracleDBPU2");
EntityManager em = emf.createEntityManager();
UsrBooksJpaController booksController = new UsrBooksJpaController(emf);
List<UsrBooks> usrBooksAll = booksController.findUsrBooksEntities();
System.out.println(usrBooksAll);
the code works, even prints data from the table, just getting the error
Upvotes: 1
Views: 935
Reputation: 42114
Possibly in persistence.xml eclipselink.ddl-generation property does have value create-tables
. Try none
instead:
<property name="eclipselink.ddl-generation" value="none"/>
Upvotes: 1