Thanks, I will try.
Would be nice if all JPA could produce the same results.

Paolo 


-----Messaggio originale-----
Da: Jay D. McHugh [mailto:j...@jnwd.net] 
Inviato: martedì 3 febbraio 2009 17.47
A: users@openejb.apache.org
Oggetto: Re: R: datasource problem with hibernate and oracle

Hi Paolo,

I just wanted to make a comment on the one-to-many issue that you ran
into.  The JPA spec actually says that they should be annotated from the
'many' side.  If you do that, you should be able to get around the
lookup tables.

Or, you could take advantage of an OpenJPA specific feature annotation -
ElementJoinColumn.  Here is the syntax:

@ElementJoinColumn(name="<child table ref column>"
referencedColumnName="<parent table ref column>")

HTH,

Jay

Paolo Spadafora wrote:
> Hi David,
> Don't know if I answered you already, anyways...
> It works with hibernate, I wanted to switch to openjpa, I made several
> changes 
> to my pojo annotations to make it work, as a result I have a db schema very
> different (seems that
> Openjpa uses lookup tables even for one-to-many relationship).
> Last note, is there any plan to have eclipse debug support?
> To be able to work seriously I need to debug tomcat with embed openejb using
> WTP,
> I know how to do it with remote debugger but doesn’t work well, have to
> re-deploy my ejb+webapp each time.
> Thank you.
> 
> bye 
> 
> 
> 
> Paolo,
> 
> 
> 
> -----Messaggio originale-----
> Da: David Blevins [mailto:david.blev...@visi.com] 
> Inviato: giovedì 29 gennaio 2009 23.31
> A: users@openejb.apache.org
> Oggetto: Re: datasource problem with hibernate and oracle
> 
> Hi Paulo,
> 
> Thanks for the follow up.  (log was sent offline).
> 
> The log output did help quite a bit.  The datasources appear to be  
> configured correctly, but for some reason the system was unable to  
> determine if they were JtaManaged or not.  I was wracking my brain  
> when I thought of comment Jens Toerber made recently about spaces on  
> the end of properties getting preserved (this is what  
> java.util.Properties will do when loading properties files).  I  
> tweaked my mockup of your config to add a space on the end of the  
> JtaManaged value so it was "true " and sure enough it caused the issue  
> you're seeing.
> 
> I've fixed this and logged it as a bug.
> 
>    https://issues.apache.org/jira/browse/OPENEJB-995
> 
> -David
> 
> On Jan 29, 2009, at 12:12 AM, David Blevins wrote:
> 
>> Hi Paolo,
>>
>> I've been looking into this and have been able to reproduce the  
>> issue.  I copied and pasted your configs into an openejb-3.1 install  
>> and everything configured as expected.  To move things forward I've  
>> added more debug messages to a few key places in the persistence  
>> context configuration code.  If you could give this snapshot of  
>> 3.1.1 a try and send back the log output, that would be great.
>>
>> To get the new messages you need to adjust the logging.properties to  
>> set "log4j.category.OpenEJB.startup.config" to "debug".
>>
>> I've uploaded a new snapshot binary here:
>>
>>  http://people.apache.org/~dblevins/openejb-3.1.1-SNAPSHOT.zip
>>
>> As well as published new snapshots to the maven repo.
>>
>>
>> -David
>>
>>
>> On Jan 23, 2009, at 1:02 AM, Paolo Spadafora wrote:
>>
>>> Hi David,
>>>
>>> I use the same settings for managed and unmanaged datasource  
>>> because I got
>>> an error or a warning (can't remember) if I don't put both inside the
>>> persistence.xml.
>>>
>>> I have 2 Persistence Unit and 2 DataSource (4 DS because I declare  
>>> XxDS and
>>> XxDSUn), one datasource refers to a schema with read/write and TX.  
>>> The other
>>> points to another schema which is used for read only queries,  
>>> sometimes they
>>> are in 2 different DB.
>>>
>>>
>>>
>>> <persistence-unit name="MyOrclEM" transaction-type="JTA">
>>>
>>>           <provider>org.hibernate.ejb.HibernatePersistence</provider>
>>>
>>>           <jta-data-source>MyOrclDS</jta-data-source>
>>>
>>>           <non-jta-data-source>MyOrclDSUn</non-jta-data-source>
>>>
>>>           <class>
>>>
>>>     [pojo here]
>>>
>>>           </class>
>>>
>>>           <properties>
>>>
>>>                 <property name="hibernate.dialect"
>>>
>>>
>>>
>>> value="org.hibernate.dialect.Oracle10gDialect" />
>>>
>>>                 <property name="hibernate.show_sql" value="false" />
>>>
>>>                 <property name="hibernate.cache.provider_class"
>>>
>>>
>>>
>>> value="org.hibernate.cache.HashtableCacheProvider" />
>>>
>>>                 <property
>>>
>>> name="hibernate.transaction.manager_lookup_class"
>>>
>>>
>>>
>>> value="org.hibernate.transaction.JBossTransactionManagerLookup" />
>>>
>>>           </properties>
>>>
>>>     </persistence-unit>
>>>
>>>
>>>
>>> I user latest version of OpenEJB (3.1).
>>>
>>> I use oracle XE.
>>>
>>> I have to say that I am migrating from JBoss 4.x, in JBoss it works
>>> perfectly.
>>>
>>>
>>>
>>> Thank you.
>>>
>>>
>>>
>>> Regards,
>>>
>>> Paolo
>>>
>>>
>>> 2009/1/21 David Blevins <david.blev...@visi.com>
>>>
>>>> Hi Paolo,
>>>>
>>>> Something interesting is going on.
>>>>
>>>> The openejb.xml looks great and the persistence-unit declaration  
>>>> for "MyEM"
>>>> looks perfect.  Can you post the declaration for the "MyOrclEM"
>>>> persistence-unit?  Even if the MyOrclEM declaration was somehow  
>>>> flawed I
>>>> wouldn't expect the outcome you got.  We've got a large amount of  
>>>> tests[1]
>>>> for this feature.  We should be able to plug your config into  
>>>> those tests
>>>> and figure out what's going on.
>>>>
>>>> On a side note, it looks like the datasources "MyDS" and  
>>>> "MyOrclDS" are
>>>> identical as are "MyDSUn" and "MyOrclDS".  If you're willing to  
>>>> give some
>>>> details on what motivates that, that'd be great.  I suspect there  
>>>> is a
>>>> feature waiting to be added there that might help you reduce  
>>>> redundant
>>>> configuration.
>>>>
>>>> Also, what OpenEJB version are you using?
>>>>
>>>> -David
>>>>
>>>> [1]
>>>>
> http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1/container/openejb-c
> ore/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.j
> ava
>>>>
>>>> On Jan 19, 2009, at 4:19 AM, Paolo Spadafora wrote:
>>>>
>>>> Hello,
>>>>> I have a problem with datasource, looks like openejb is using an  
>>>>> hsqldb
>>>>> database instead of Oracle.
>>>>>
>>>>>
>>>>>
>>>>> The error is: "table not found"
>>>>>
>>>>>
>>>>>
>>>>> INFO: building session factory
>>>>>
>>>>> 19-gen-2009 12.43.36 org.hibernate.impl.SessionFactoryObjectFactory
>>>>> addInstance
>>>>>
>>>>> INFO: Not binding factory to JNDI, no JNDI name configured
>>>>>
>>>>> 19-gen-2009 12.43.36 org.hibernate.tool.hbm2ddl.SchemaUpdate  
>>>>> execute
>>>>>
>>>>> INFO: Running hbm2ddl schema update
>>>>>
>>>>> 19-gen-2009 12.43.36 org.hibernate.tool.hbm2ddl.SchemaUpdate  
>>>>> execute
>>>>>
>>>>> INFO: fetching database metadata
>>>>>
>>>>> 19-gen-2009 12.43.36 org.hibernate.tool.hbm2ddl.SchemaUpdate  
>>>>> execute
>>>>>
>>>>> GRAVE: could not get database metadata
>>>>>
>>>>> java.sql.SQLException: Tabella non trovata in statement [select
>>>>> sequence_name fr
>>>>>
>>>>> om user_sequences]
>>>>>
>>>>>     at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
>>>>>
>>>>>     at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
>>>>>
>>>>>     at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingSt
>>>>>
>>>>> atement.java:208)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingSt
>>>>>
>>>>> atement.java:208)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMet
>>>>>
>>>>> adata.java:128)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.j
>>>>>
>>>>> ava:46)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.j
>>>>>
>>>>> ava:39)
>>>>>
>>>>>     at
>>>>> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java: 
>>>>> 129
>>>>>
>>>>> )
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
>>>>>
>>>>> 314)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
>>>>>
>>>>> a:1300)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
>>>>>
>>>>> ionConfiguration.java:859)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
>>>>>
>>>>> figuration.java:669)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
>>>>>
>>>>> ctory(HibernatePersistence.java:132)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.openejb.assembler.classic.PersistenceBuilder.createEntityM
>>>>>
>>>>> anagerFactory(PersistenceBuilder.java:183)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.openejb.assembler.classic.Assembler.createApplication(Asse
>>>>>
>>>>> mbler.java:487)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.openejb.assembler.classic.Assembler.createApplication(Asse
>>>>>
>>>>> mbler.java:447)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.openejb.assembler.classic.Assembler.buildContainerSystem(A
>>>>>
>>>>> ssembler.java:365)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.openejb.assembler.classic.Assembler.build(Assembler.java:2
>>>>>
>>>>> 77)
>>>>>
>>>>>     at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:150)
>>>>>
>>>>>     at org.apache.openejb.OpenEJB.init(OpenEJB.java:299)
>>>>>
>>>>>     at
>>>>> org 
>>>>> .apache.openejb.tomcat.catalina.TomcatLoader.init(TomcatLoader.jav
>>>>>
>>>>> a:121)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Openejb.xml:
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>
>>>>> <openejb>
>>>>>
>>>>>
>>>>>
>>>>> <Container id="My CMP Container" type="CMP_ENTITY">
>>>>>
>>>>>
>>>>>
>>>>> </Container>
>>>>>
>>>>> <Container id="My BMP Container" type="BMP_ENTITY">
>>>>>
>>>>>
>>>>>
>>>>> PoolSize 10
>>>>>
>>>>>
>>>>>
>>>>> </Container>
>>>>>
>>>>> <Container id="My Stateful Container" type="STATEFUL">
>>>>>
>>>>> Passivator   org.apache.openejb.core.stateful.SimplePassivater
>>>>>
>>>>>
>>>>>
>>>>> TimeOut  20
>>>>>
>>>>>
>>>>>
>>>>> Capacity  1000
>>>>>
>>>>>
>>>>>
>>>>> BulkPassivate  100
>>>>>
>>>>>
>>>>>
>>>>> </Container>
>>>>>
>>>>>
>>>>>
>>>>> <Container id="My Stateless Container" type="STATELESS">
>>>>>
>>>>> TimeOut  0
>>>>>
>>>>>
>>>>>
>>>>> PoolSize  10
>>>>>
>>>>>
>>>>>
>>>>> StrictPooling  true
>>>>>
>>>>> </Container>
>>>>>
>>>>>
>>>>>
>>>>> <Resource id="MyDS" type="DataSource">
>>>>>
>>>>> JdbcDriver oracle.jdbc.OracleDriver
>>>>>
>>>>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>>>>
>>>>> UserName username
>>>>>
>>>>> Password password
>>>>>
>>>>> JtaManaged true
>>>>>
>>>>> </Resource>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> <Resource id="MyDSUn" type="DataSource">
>>>>>
>>>>> JdbcDriver oracle.jdbc.OracleDriver
>>>>>
>>>>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>>>>
>>>>> UserName username
>>>>>
>>>>> Password password
>>>>>
>>>>> JtaManaged false
>>>>>
>>>>> </Resource>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> <Resource id="MyOrclDS" type="DataSource">
>>>>>
>>>>> JdbcDriver oracle.jdbc.OracleDriver
>>>>>
>>>>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>>>>
>>>>> UserName username
>>>>>
>>>>> Password password
>>>>>
>>>>> JtaManaged true
>>>>>
>>>>> </Resource>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> <Resource id="MyOrclDSUn"  type="DataSource">
>>>>>
>>>>> JdbcDriver oracle.jdbc.OracleDriver
>>>>>
>>>>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>>>>
>>>>> UserName username
>>>>>
>>>>> Password password
>>>>>
>>>>> JtaManaged false
>>>>>
>>>>> </Resource>
>>>>>
>>>>>
>>>>>
>>>>> <Deployments dir="apps/" />
>>>>>
>>>>>
>>>>>
>>>>> </openejb>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Persistence.xml:
>>>>>
>>>>> <persistence 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";
>>>>>
>>>>>   version="1.0">
>>>>>
>>>>>   <persistence-unit name="MyEM" transaction-type="JTA" >
>>>>>
>>>>>         <provider>org.hibernate.ejb.HibernatePersistence</provider>
>>>>>
>>>>>         <jta-data-source>MyDS</jta-data-source>
>>>>>
>>>>>         <non-jta-data-source>MyDSUn</non-jta-data-source>
>>>>>
>>>>>         <class>.</class>
>>>>>
>>>>>         [pojo classes]
>>>>>
>>>>>
>>>>>
>>>>>         <exclude-unlisted-classes>false</exclude-unlisted-classes>
>>>>>
>>>>>         <properties>
>>>>>
>>>>>             <property name="hibernate.dialect"
>>>>>
>>>>>                      
>>>>> value="org.hibernate.dialect.Oracle10gDialect" />
>>>>>
>>>>>               <property name="hibernate.show_sql" value="true" />
>>>>>
>>>>>               <property name="hibernate.cache.provider_class"
>>>>>
>>>>>                      
>>>>> value="org.hibernate.cache.HashtableCacheProvider"
>>>>> />
>>>>>
>>>>>               <property
>>>>> name="hibernate.transaction.manager_lookup_class"
>>>>>
>>>>>
>>>>> value="org.hibernate.transaction.JBossTransactionManagerLookup" />
>>>>>
>>>>>               <property name="hibernate.hbm2ddl.auto"  
>>>>> value="update" />
>>>>>
>>>>>               <property name="hibernate.jdbc.batch_size"  
>>>>> value="0"/>
>>>>>
>>>>>         </properties>
>>>>>
>>>>>   </persistence-unit>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Openejb.log (why is openejb "Adjusting" the datasource for my EM?)
>>>>>
>>>>> 2009-01-19 12:43:30,217 - INFO  - Configuring Service(id=Tomcat  
>>>>> Security
>>>>> Service, type=SecurityService, provider-id=Tomcat Security Service)
>>>>>
>>>>> 2009-01-19 12:43:30,220 - INFO  - Configuring Service(id=Default
>>>>> Transaction
>>>>> Manager, type=TransactionManager, provider-id=Default Transaction  
>>>>> Manager)
>>>>>
>>>>> 2009-01-19 12:43:30,222 - INFO  - Configuring Service(id=MyDS,
>>>>> type=Resource, provider-id=Default JDBC Database)
>>>>>
>>>>> 2009-01-19 12:43:30,224 - INFO  - Configuring Service(id=MyDSUn,
>>>>> type=Resource, provider-id=Default JDBC Database)
>>>>>
>>>>> 2009-01-19 12:43:30,225 - INFO  - Configuring Service(id=MyOrclDS,
>>>>> type=Resource, provider-id=Default JDBC Database)
>>>>>
>>>>> 2009-01-19 12:43:30,227 - INFO  - Configuring  
>>>>> Service(id=MyOrclDSUn,
>>>>> type=Resource, provider-id=Default JDBC Database)
>>>>>
>>>>> 2009-01-19 12:43:30,230 - INFO  - Configuring Service(id=My CMP  
>>>>> Container,
>>>>> type=Container, provider-id=Default CMP Container)
>>>>>
>>>>> 2009-01-19 12:43:30,232 - INFO  - Configuring Service(id=My BMP  
>>>>> Container,
>>>>> type=Container, provider-id=Default BMP Container)
>>>>>
>>>>> 2009-01-19 12:43:30,234 - INFO  - Configuring Service(id=My  
>>>>> Stateful
>>>>> Container, type=Container, provider-id=Default Stateful Container)
>>>>>
>>>>> 2009-01-19 12:43:30,235 - INFO  - Configuring Service(id=My  
>>>>> Stateless
>>>>> Container, type=Container, provider-id=Default Stateless Container)
>>>>>
>>>>> 2009-01-19 12:43:30,934 - INFO  - Configuring enterprise  
>>>>> application:
>>>>> C:\dev\apache-tomcat-6.0.18\apps\my-ejb.jar
>>>>>
>>>>> 2009-01-19 12:43:31,408 - INFO  - Configuring  
>>>>> PersistenceUnit(name=MyEM,
>>>>> provider=org.hibernate.ejb.HibernatePersistence)
>>>>>
>>>>> 2009-01-19 12:43:31,413 - INFO  - Configuring Service(id=Default  
>>>>> JDBC
>>>>> Database, type=Resource, provider-id=Default JDBC Database)
>>>>>
>>>>> 2009-01-19 12:43:31,415 - INFO  - Configuring Service(id=Default  
>>>>> Unmanaged
>>>>> JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC  
>>>>> Database)
>>>>>
>>>>> 2009-01-19 12:43:31,416 - INFO  - Auto-creating a Resource with id
>>>>> 'Default
>>>>> JDBC Database' of type 'DataSource for 'MyEM'.
>>>>>
>>>>> 2009-01-19 12:43:31,416 - INFO  - Auto-creating a Resource with id
>>>>> 'Default
>>>>> Unmanaged JDBC Database' of type 'DataSource for 'MyEM'.
>>>>>
>>>>> 2009-01-19 12:43:31,416 - INFO  - Configuring
>>>>> PersistenceUnit(name=MyOrclEM,
>>>>> provider=org.hibernate.ejb.HibernatePersistence)
>>>>>
>>>>> 2009-01-19 12:43:31,417 - INFO  - Adjusting MyOrclEM <jta-data- 
>>>>> source> to
>>>>> 'Default JDBC Database'
>>>>>
>>>>> 2009-01-19 12:43:31,418 - INFO  - Adjusting MyOrclEM <non-jta- 
>>>>> data-source>
>>>>> to 'Default Unmanaged JDBC Database'
>>>>>
>>>>> 2009-01-19 12:43:31,447 - INFO  - Enterprise application
>>>>> "C:\dev\magsuite\ms-v2\apache-tomcat-6.0.18\apps\msuite-ejb.jar"  
>>>>> loaded.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> All necessary jars are there: hibernates jars and oracle drivers.
>>>>>
>>>>>
>>>>>
>>>>> Thank you.
>>>>>
>>>>>
>>>>>
>>>>> Regards,
>>>>>
>>>>> Paolo
>>>>>
>>>>>
>>
> 
> 
> 
> 


Reply via email to