0

When I attempt to use item.persist(),it is failing. While I cannot see the final sql statement, it does show the call before binding the parameters and the schema is missing.
When I am creating the Entity Manager I am using the map of properties approach. So, perhaps I am using the wrong property name, I am working from various examples on the web. I am using EclipseLink and accessing a Netezza database. After I create the EntityManager, here is the output from getProperties():

em properties:

{javax.persistence.jdbc.url=jdbc:netezza://server.com:5480/databaseName, javax.persistence.jdbc.password=xxxx, openjpa.jdbc.Schema=RT, javax.persistence.jdbc.driver=org.netezza.Driver, javax.persistence.jdbc.user=xxxx}

The openjpa.jdbc.Schema=RT is set to the right value in the properties.

UPDATED: I also have the following values in my persistence.xml:

    <properties>
        <property name="openjpa.jdbc.Schema" value="RT" />
        <property name="javax.persistence.jdbc.url" value="jdbc:netezza://server.com:5480/database"/>
        <property name="javax.persistence.jdbc.user" value="xxxxx"/>
        <property name="javax.persistence.jdbc.password" value="xxxx"/>
        <property name="javax.persistence.jdbc.driver" value="org.netezza.Driver"/>
    </properties>

What is the correct property for the schema? That is not listed in any of the properties suggested. It is required to find the correct table...

Jay Witherspoon
  • 165
  • 1
  • 11
  • have you tried this one? http://stackoverflow.com/questions/3211138/jpa-eclipselink-how-to-change-default-schema – gerosalesc Aug 21 '15 at 17:11

2 Answers2

0

I think the "openjpa.jdbc.Schema" property is not correct, because it seems to correspond to a configuration of the Apache OpenJPA implementation

To implement EclipseLink is necessary to define the following properties in your persistence.xml

<property name = "eclipselinkj.dbc.driver" value = "org.netezza.driver" />
<property name = "eclipselink.jdbc.url" value = "jdbc: Netezza: //server.com: 5480 / databaseName" />
<property name = "eclipselink.jdbc.password" value = "xxxx" />
<property name = "eclipselink.jdbc.user" value = "user" />

See: Configuring the Persistence Unit

or if you want to use the standard JPA

<property name = "javax.persistence.jdbc.driver" value = "org.netezza.driver" />
<property name = "javax.persistence.jdbc.url" value = "jdbc: Netezza: //server.com: 5480 / databaseName" />
<property name = "javax.persistence.jdbc.password" value = "xxxx" />
<property name = "javax.persistence.jdbc.user" value = "user" />
Carlos Laspina
  • 2,013
  • 4
  • 27
  • 44
  • Thank you for the suggestion, I did also have those properties in persistence.xml, please see my updated problem description above. – Jay Witherspoon Aug 21 '15 at 17:15
  • This same question was asked and answered here: [JPA - EclipseLink - How to change default schema](http://stackoverflow.com/questions/3211138/jpa-eclipselink-how-to-change-default-schema) You can override the schema for the entire persistence unit using an orm.xml file, or define it within each table annotation or xml element as needed. – Carlos Laspina Aug 21 '15 at 17:28
  • "INSERT INTO RT.PERSON " the artcle about changing default schema worked. Note, I at first used the JPA tool in eclipse to add the schema. It created the orm.xml file and updated persistence.xml with its location. However, it only added the SCHEMA line and not the and lines. I may have used the tool wrong... But something to check for. Added those lines like the example, and it worked. Thanks again! – Jay Witherspoon Aug 21 '15 at 19:43
  • It is a pleasure, do not forget to mark the answer as answered, so other people can see it. – Carlos Laspina Aug 24 '15 at 18:29
0

The property openjpa.jdbc.Schema works only with OpenJPA implementation,definitely not with eclipselink. Standard way in JPA to specify schema is either per each entity using schema property of@Table annotation. Or if you need to specify it for all entities, you create an additional mapping file besides persistence.xml, where you may define default schema in XML:

persistence.xml:

...
  <persistence-unit name="MySchemaPU"  transaction-type="JTA">
     <mapping-file>META-INF/orm.xml</mapping-file>

And new file orm.xml in META-INF folder:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
                 version="1.0">
 <persistence-unit-metadata>

  <persistence-unit-defaults>
   <schema>RT</schema>
  </persistence-unit-defaults>
 </persistence-unit-metadata>
</entity-mappings
OndroMih
  • 7,280
  • 1
  • 26
  • 44