java - JPA/EclipseLink Error in Creating Tables -
i trying create table using eclipselink. java class being used :-
import java.util.date; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.temporal; import javax.persistence.temporaltype; import javax.persistence.id; @entity public class submissions { @id @generatedvalue(strategy = generationtype.identity) private long id; private string xid; private string y; @temporal(temporaltype.date) private date udate; private string level; private string state; public submissions() { } //all relevant getter , setter functions }
the relevant persistence xml in question follows:-
<persistence-unit name="submissionids"> <provider>org.eclipse.persistence.jpa.persistenceprovider</provider> <class>com.obp.selenium.dataobjects.originationsubmissions</class> <properties> <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.oracledriver" /> <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:orcl" /> <property name="javax.persistence.jdbc.user" value="------" /> <property name="javax.persistence.jdbc.password" value="------" /> <!-- eclipselink should create database schema automatically --> <property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> <!-- <property name="eclipselink.canonicalmodel.subpackage" value="originationsubmissions" /> --> </properties> </persistence-unit>
we use standard method implementing entitymanagerfactory :-
entitymanagerfactory factory = persistence.createentitymanagerfactory("submissionids"); entitymanager em = factory.createentitymanager(); em.gettransaction().begin(); em.gettransaction().commit(); em.close();
however keep getting following errors :-
el warning]: 2017-04-07 14:04:53.768--serversession(1650327539)--exception [eclipselink-4002] (eclipse persistence services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.databaseexception internal exception: java.sql.sqlsyntaxerrorexception: ora-00904: : invalid identifier
error code: 904 call: create table submissions (id number(19) not null, xid varchar2(255) null, y varchar2(255) null, level varchar2(255) null, state varchar2(255) null, udate date null, primary key (id)) query: datamodifyquery(sql="create table submissions (id number(19) not null, xid varchar2(255) null, y varchar2(255) null, level varchar2(255) null, state varchar2(255) null, udate date null, primary key (id))")
avtually eclipse reported bug rises when there reserved word usage can fine here :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=260637.
the problem comes using reserved word dont know dbms, if mysql attributs xid , level reserved word. can find mysql reserved word here : https://dev.mysql.com/doc/refman/5.7/en/keywords.html.
you can se sql code used build tables there column name update of type date
udate date null
so opinion, need watch attribut name on udate
Comments
Post a Comment