openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <adam....@cyberspaceroad.org>
Subject Re: specifying schema in snapshot 1.1.0
Date Fri, 11 Jan 2008 12:29:49 GMT
I cannot see why this is not working for me.

I stripped my project down to the simplest elements possible and still had the 
problem.

I have logged it as a Jira at https://issues.apache.org/jira/browse/OPENJPA-483 
and included the zipped up project, in case it helps if anyone wants to look at it.

Thanks
Adam


Adam Hardy on 09/01/08 12:08, wrote:
> 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 <adam.sql@cyberspaceroad.org> 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)


Mime
View raw message