I'm using Eclipselink as JPA provider and Embedded Apache Derby database. When I run the project, I get exception as follows:
Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "NOT" at line 1, column 31.
Error Code: -1
Call: CREATE TABLE ITEM (ID VARCHAR NOT NULL, CODE VARCHAR, EXCLUSIVETAX NUMBER(10,5), NAME VARCHAR, UNITPRICE NUMBER(10,5), PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE ITEM (ID VARCHAR NOT NULL, CODE VARCHAR, EXCLUSIVETAX NUMBER(10,5), NAME VARCHAR, UNITPRICE NUMBER(10,5), PRIMARY KEY (ID))")
[EL Warning]: 2013-03-06 18:04:41.827--ServerSession(1650627452)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at line 1, column 71.
Error Code: -1
Call: CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMBER(19), PRIMARY KEY (SEQ_NAME))
Query: DataModifyQuery(sql="CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMBER(19), PRIMARY KEY (SEQ_NAME))")
[EL Info]: 2013-03-06 18:04:41.856--ServerSession(1650627452)--Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
The persistence.xml is like this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="StockKeeperPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.mycompany.entities.stock.Item</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:sampledb;create=true"/>
<property name="javax.persistence.jdbc.password" value="app"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.user" value="app"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
What is the problem here? Is NOT
not allowed in that statement? If not allowed, why the query is framed so?