That's interesting. Thank you very much for the help.
I ran that verification but still the query i'm testing doesn't contain the
schema name prefix on the table in the SQL.
I put all the properties in the persistence.xml (and in debugging, I see the
schema name is added to the metadata - at least in one place, although obviously
not enough)
<properties>
<property name="openjpa.jdbc.Schema" value="DEV" />
<property name="openjpa.ConnectionUserName" value="sa" />
<property name="openjpa.ConnectionPassword" value="" />
<property name="openjpa.ConnectionURL"
value="jdbc:hsqldb:mem:TRADING_CODE" />
<property name="openjpa.ConnectionDriverName"
value="org.hsqldb.jdbcDriver" />
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)" />
<property name="openjpa.jdbc.DBDictionary"
value="org.apache.openjpa.jdbc.sql.HSQLDictionary" />
<property name="openjpa.Log" value="log4j" />
<property name="openjpa.Id" value="[PatternRepo OpenJPA]" />
</properties>
and instantiated the EntityManagerFactory without any extra properties:
entityManagerFactory =
Persistence.createEntityManagerFactory(persistenceUnitName);
I'm also double-checking that the schema exists during the test, using
metaData = connection.getMetaData();
rs = metaData.getSchemas();
while (rs.next())
{
logger.debug("schema: " + rs.getString("TABLE_SCHEM"));
}
Prashant Bhat on 09/01/08 10:52, wrote:
Yes, I see the schema name prefixed in the query and of course it is
needed to load from db.
Are you passing those properties to the emf during creation? Instead,
you can (just to verify) try setting them in persistence.xml by adding
a properties element like this:
<persistence-unit name="PatternRepo">
.....
<properties>
<property name="openjpa.jdbc.Schema" value="DEV" />
</properties>
</persistence-unit>
or if you're using spring framework, then (I externalize these
properties using PropertyPlaceholderConfigurer)
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter" />
</property>
<property name="jpaPropertyMap">
<map>
<entry key="openjpa.jdbc.Schema" value="DEV" />
</map>
</property>
</bean>
//
Prashant
On Jan 9, 2008 6:31 PM, Adam Hardy <[EMAIL PROTECTED]> wrote:
If you see the schema names in the debug logging of query SQL, then maybe you
can see something in my config that causes my issue - but if you aren't meant to
see the schema name in the logging, it could be something as simple as a
database incompatibility.
I checked that the schema exists! It does.
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="PatternRepo">
<description>Pattern Repo JPA Config</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>org/permacode/patternrepo/orm/Category.xml</mapping-file>
<mapping-file>org/permacode/patternrepo/orm/Market.xml</mapping-file>
<mapping-file>org/permacode/patternrepo/orm/Code.xml</mapping-file>
<mapping-file>org/permacode/patternrepo/orm/TestResult.xml</mapping-file>
<mapping-file>org/permacode/patternrepo/orm/TradingParam.xml</mapping-file>
</persistence-unit>
</persistence>
orm.xml:
<?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>
<xml-mapping-metadata-complete />
<persistence-unit-defaults>
<schema>DEV</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
the properties I set in code:
openjpa.ConnectionUserName=sa
openjpa.ConnectionPassword=
openjpa.ConnectionURL=jdbc:hsqldb:mem:TRADING_CODE
openjpa.ConnectionDriverName=org.hsqldb.jdbcDriver
openjpa.jdbc.Schema=DEV
openjpa.jdbc.SchemaFactory=native(ForeignKeys=true)
openjpa.jdbc.DBDictionary=org.apache.openjpa.jdbc.sql.HSQLDictionary
openjpa.Log=log4j
openjpa.Id=[PatternRepo OpenJPA]
The mappings won't help but this is it:
openjpa.MetaDataFactory:jpa(Resources=org/permacode/patternrepo/orm/Category.xml;
org/permacode/patternrepo/orm/Market.xml;
org/permacode/patternrepo/orm/Code.xml;
org/permacode/patternrepo/orm/TestResult.xml;
org/permacode/patternrepo/orm/TradingParam.xml;
org/permacode/patternrepo/orm/CategoryCodeLink.xml;
org/permacode/patternrepo/orm/TestQueries.xml)