I am trying to create a table using EclipseLink. The java class being used is :-
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 and setter functions
}
The relevant persistence xml in question is as 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 the 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 the standard method is by implementing the EntityManagerFactory as :-
EntityManagerFactory factory = Persistence.createEntityManagerFactory("SubmissionIds");
EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
em.getTransaction().commit();
em.close();
However I keep getting the 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))")
persistence.xml
there is not persistence unit called"Trainstops"
which is you're trying to instantiate here:Persistence.createEntityManagerFactory("Trainstops")
. The persistence unit is calledSubmissionIds
and the entity this PU maps is calledOriginationSubmissions
notSubmissions
. You should check both persistence unit name and class name are the right ones. – dic19