Re: OpenJPA Transaction configuration

2007-03-01 Thread Abe White
If you set the version field of an instance to a non-default value,  
OpenJPA assumes the instance was detached, or that you're actively  
trying to make it behave as a detached instance.

___
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.


RE: OpenJPA Transaction configuration

2007-03-01 Thread Patrick Linskey
 Here is a link to the source (and no version field):

There is a version field in there. How are you invoking the non-default
constructor? As Abe mentioned, if your version field is set to a value
other than the Java default (0 in this case), OpenJPA will assume that
the instance is detached.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

___
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

 -Original Message-
 From: Matthieu Riou [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, February 28, 2007 9:51 PM
 To: Patrick Linskey
 Cc: open-jpa-dev@incubator.apache.org
 Subject: Re: OpenJPA  Transaction configuration
 
 Here is a link to the source (and no version field):
 
 http://svn.apache.org/repos/asf/incubator/ode/trunk/dao-jpa/sr
c/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java 
 
 How can I try to change the default detach manager? Which one 
 should I use instead?
 
 Thanks!
 Matthieu
 
 
 On 2/28/07, Patrick Linskey  [EMAIL PROTECTED] wrote:
 
   Can you post the source for ProcessDAOImpl? Also, are 
 there any other 
   OpenJPA properties in your configuration? Finally, I'm 
 assuming that
   you're using a somewhat-current 0.9.7-SNAPSHOT. Correct 
 me if I'm wrong.
   
But shouldn't I worry about the fact that a brand new 
instance is detached? I could be wrong but it looks
like it's more a symptom of
   
   I believe that you should. I think I remember reading 
 something about
   this recently, but I don't remember the details. My 
 suspicion is that 
   you don't have an @Version field, and you're using the 
 default detach
   manager. IIRC, this combination leaves OpenJPA with no 
 way to detect a
   detached object vs. a new object, and we default to 
 detached. I thought 
   that we had improved the docs around this at the least; 
 certainly, it'd
   be good to figure out your particulars and make sure 
 that this is
   clearer for others.
   
   (IIRC, the default detach manager uses a heuristic on 
 the value in the 
   version field to determine whether an instance is new 
 or detached.
   OpenJPA supports more flexible detach managers that can 
 do fun things
   like providing useful errors when attempting to 
 navigate past the end of
   a detached object graph, and fine-grained tracking of 
 changes made while
   detached. But it's not serialization-compatible with 
 the unenhanced
   code, meaning that you need to put the enhanced classes 
 into your client 
   tier, which I think that we decided was a bad default.)
   
   -Patrick
   
   --
   Patrick Linskey
   BEA Systems, Inc.
   
   
 __
 _
   Notice:  This email message, together with any 
 attachments, may contain 
   information  of  BEA Systems,  Inc.,  its subsidiaries  
 and  affiliated
   entities,  that may be confidential,  proprietary,  
 copyrighted  and/or
   legally privileged, and is intended solely for the use 
 of the individual 
   or entity named in this message. If you are not the 
 intended recipient,
   and have received this message in error, please 
 immediately return this
   by email and then delete it.
   
-Original Message- 
From: Matthieu Riou [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 28, 2007 7:50 PM
To: Pinaki Poddar
Cc: open-jpa-dev@incubator.apache.org 
 mailto:open-jpa-dev@incubator.apache.org 
Subject: Re: OpenJPA  Transaction configuration
   
Thanks! But shouldn't I worry about the fact that a brand new
instance is
detached? I could be wrong but it looks like it's 
 more a symptom of 
something wrong in my configuration, no?
   
On 2/28/07, Pinaki Poddar [EMAIL PROTECTED] wrote:

   instead of _em.persist(ret);
 try 
   _em.merge(ret);

 as ret is detached instance rather than new.



 Pinaki Poddar
 BEA Systems
 415.402.7317


 -Original Message-
 From: Matthieu Riou [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 28, 2007 6:29 PM 
 To: open-jpa-dev@incubator.apache.org
 Subject: OpenJPA  Transaction configuration

 Hi,

 I'm going back at the OpenJPA

OpenJPA Transaction configuration

2007-02-28 Thread Matthieu Riou

Hi,

I'm going back at the OpenJPA implementation for the Apache ODE project and
am still having problems with the setup. Whan I try to persist a new object
I get an exception Attempt to persist detached object. I guess the when I
instantiate my object OpenJPA can't locate its transactional context or
something related therefore assuming that the object is instantiated outside
of any persistent context.

Here is the code that creates the EntityManagerFactory:

   HashMapString, Object propMap = new HashMapString,Object();
   propMap.put(openjpa.Log, DefaultLevel=TRACE);
   propMap.put(openjpa.jdbc.DBDictionary, 
org.apache.openjpa.jdbc.sql.DerbyDictionary);
   propMap.put(openjpa.ManagedRuntime, new TxMgrProvider());
   propMap.put(openjpa.ConnectionFactory, _ds);
   propMap.put(openjpa.ConnectionFactoryMode, managed);
   propMap.put(openjpa.Log, DefaultLevel=TRACE);
   _emf = Persistence.createEntityManagerFactory(ode-dao, propMap);

And here is my object instantiation code:

   ProcessDAOImpl ret = new ProcessDAOImpl(pid,type,guid,this,version);
   System.out.println(detached  +
((PersistenceCapable)ret).pcIsDetached());
   _em.persist(ret);

My little debugging statement outputs true. I've reproduced the full log
below. I've also encapsulated to transaction manager and the transaction to
check whether OpenJPA was getting the transaction and registering a
synchronizer properly. It seems to be doing so (the log statements are just
a couple lines above the '.'). I've removed all the mapping logs just to
avoid making this too lengthy.

Any idea of what the problem could be? I'm kind of stuck on this as it's
hard to debug the enhanced code that gets called when I instantiate my
process object.

DEBUG - ODEMessageReceiver.receive(47) | Received message for
helloWorld.hello
DEBUG - ODEService.onAxisMessageExchange(96) | Starting transaction.
DEBUG - BpelEngineImpl.route(237) | Routed: svcQname {
http://ode/bpel/unit-test.wsdl}HelloService -- BpelProcess[{
http://ode/bpel/unit-test}HelloWorld2-1]
29603  ode-dao  INFO   [http-8080-Processor25] openjpa.Runtime - Starting
OpenJPA 0.9.7-incubating-SNAPSHOT
29604  ode-dao  TRACE  [http-8080-Processor25] openjpa.Runtime - Properties:
openjpa.EntityManagerFactory: default
openjpa.DataCache: false
openjpa.MetaDataFactory: jpa(Types=
org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl
;org.apache.ode.dao.jpa.CorrelationSetDAOImpl;org.apache.ode.dao.jpa.CorrelatorDAOImpl;org.apache.ode.dao.jpa.EventDAOImpl;org.apache.ode.dao.jpa.FaultDAOImpl;org.apache.ode.dao.jpa.MessageDAOImpl;org.apache.ode.dao.jpa.MessageExchangeDAOImpl;org.apache.ode.dao.jpa.MessageRouteDAOImpl;org.apache.ode.dao.jpa.PartnerLinkDAOImpl;org.apache.ode.dao.jpa.ProcessDAOImpl;org.apache.ode.dao.jpa.ProcessInstanceDAOImpl;org.apache.ode.dao.jpa.ScopeDAOImpl;org.apache.ode.dao.jpa.XmlDataDAOImpl)
openjpa.InverseManager: false
openjpa.ReadLockLevel: read
openjpa.DataCacheManager: default
openjpa.jdbc.SubclassFetchMode: join
openjpa.jdbc.UpdateManager: default
openjpa.jdbc.SynchronizeMappings: false
openjpa.NontransactionalRead: true
openjpa.QueryCompilationCache: true
openjpa.MaxFetchDepth: -1
openjpa.RetainState: true
openjpa.DynamicDataStructs: false
openjpa.BrokerFactory: jdbc
openjpa.WriteLockLevel: write
openjpa.ManagedRuntime:
org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl$TxMgrProvider
openjpa.jdbc.EagerFetchMode: parallel
openjpa.RestoreState: immutable
openjpa.jdbc.SchemaFactory: dynamic
openjpa.LockManager: version
openjpa.BrokerImpl: default
openjpa.NontransactionalWrite: true
openjpa.MetaDataRepository: default
openjpa.Log: true(DefaultLevel=TRACE)
openjpa.jdbc.ResultSetType: forward-only
openjpa.AutoDetach:
openjpa.ConnectionRetainMode: on-demand
openjpa.SavepointManager: in-mem
openjpa.jdbc.DBDictionary: derby
openjpa.Optimistic: true
openjpa.ConnectionFactoryMode: managed
openjpa.Sequence: table
openjpa.FetchGroups: default
openjpa.jdbc.Schemas:
openjpa.Id: ode-dao
openjpa.OrphanedKeyAction: log
openjpa.FlushBeforeQueries: true
openjpa.AutoClear: datastore
openjpa.Compatibility: default
openjpa.DetachState: loaded
openjpa.jdbc.LRSSize: query
openjpa.Multithreaded: false
openjpa.FetchBatchSize: -1
openjpa.jdbc.SQLFactory: default
openjpa.IgnoreChanges: false
openjpa.jdbc.MappingDefaults: jpa
openjpa.TransactionMode: local
openjpa.RetryClassRegistration: false
openjpa.jdbc.FetchDirection: forward
openjpa.ClassResolver: default
openjpa.LockTimeout: -1
openjpa.DataCacheTimeout: -1
openjpa.QueryCache: true
openjpa.jdbc.DriverDataSource: simple
openjpa.jdbc.TransactionIsolation: default
openjpa.ProxyManager: default
29604  ode-dao  TRACE  [http-8080-Processor25] openjpa.MetaData - Using
metadata factory 
[EMAIL PROTECTED].
29604  ode-dao  INFO   [http-8080-Processor25] openjpa.jdbc.JDBC - Using
dictionary class org.apache.openjpa.jdbc.sql.DerbyDictionary.
WARN - BPELDAOConnectionFactoryImpl$DebugTxMgr.getTransaction(130) | JPA get
transaction
WARN 

RE: OpenJPA Transaction configuration

2007-02-28 Thread Pinaki Poddar
  instead of _em.persist(ret);
try
  _em.merge(ret);

as ret is detached instance rather than new.



Pinaki Poddar
BEA Systems
415.402.7317  


-Original Message-
From: Matthieu Riou [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 28, 2007 6:29 PM
To: open-jpa-dev@incubator.apache.org
Subject: OpenJPA  Transaction configuration

Hi,

I'm going back at the OpenJPA implementation for the Apache ODE project
and am still having problems with the setup. Whan I try to persist a new
object I get an exception Attempt to persist detached object. I guess
the when I instantiate my object OpenJPA can't locate its transactional
context or something related therefore assuming that the object is
instantiated outside of any persistent context.

Here is the code that creates the EntityManagerFactory:

HashMapString, Object propMap = new HashMapString,Object();
propMap.put(openjpa.Log, DefaultLevel=TRACE);
propMap.put(openjpa.jdbc.DBDictionary, 
org.apache.openjpa.jdbc.sql.DerbyDictionary);
propMap.put(openjpa.ManagedRuntime, new TxMgrProvider());
propMap.put(openjpa.ConnectionFactory, _ds);
propMap.put(openjpa.ConnectionFactoryMode, managed);
propMap.put(openjpa.Log, DefaultLevel=TRACE);
_emf = Persistence.createEntityManagerFactory(ode-dao,
propMap);

And here is my object instantiation code:

ProcessDAOImpl ret = new
ProcessDAOImpl(pid,type,guid,this,version);
System.out.println(detached  +
((PersistenceCapable)ret).pcIsDetached());
_em.persist(ret);

My little debugging statement outputs true. I've reproduced the full
log below. I've also encapsulated to transaction manager and the
transaction to check whether OpenJPA was getting the transaction and
registering a synchronizer properly. It seems to be doing so (the log
statements are just a couple lines above the '.'). I've removed all
the mapping logs just to avoid making this too lengthy.

Any idea of what the problem could be? I'm kind of stuck on this as it's
hard to debug the enhanced code that gets called when I instantiate my
process object.

DEBUG - ODEMessageReceiver.receive(47) | Received message for
helloWorld.hello DEBUG - ODEService.onAxisMessageExchange(96) | Starting
transaction.
DEBUG - BpelEngineImpl.route(237) | Routed: svcQname {
http://ode/bpel/unit-test.wsdl}HelloService -- BpelProcess[{
http://ode/bpel/unit-test}HelloWorld2-1]
29603  ode-dao  INFO   [http-8080-Processor25] openjpa.Runtime -
Starting
OpenJPA 0.9.7-incubating-SNAPSHOT
29604  ode-dao  TRACE  [http-8080-Processor25] openjpa.Runtime -
Properties:
openjpa.EntityManagerFactory: default
openjpa.DataCache: false
openjpa.MetaDataFactory: jpa(Types=
org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl
;org.apache.ode.dao.jpa.CorrelationSetDAOImpl;org.apache.ode.dao.jpa.Cor
relatorDAOImpl;org.apache.ode.dao.jpa.EventDAOImpl;org.apache.ode.dao.jp
a.FaultDAOImpl;org.apache.ode.dao.jpa.MessageDAOImpl;org.apache.ode.dao.
jpa.MessageExchangeDAOImpl;org.apache.ode.dao.jpa.MessageRouteDAOImpl;or
g.apache.ode.dao.jpa.PartnerLinkDAOImpl;org.apache.ode.dao.jpa.ProcessDA
OImpl;org.apache.ode.dao.jpa.ProcessInstanceDAOImpl;org.apache.ode.dao.j
pa.ScopeDAOImpl;org.apache.ode.dao.jpa.XmlDataDAOImpl)
openjpa.InverseManager: false
openjpa.ReadLockLevel: read
openjpa.DataCacheManager: default
openjpa.jdbc.SubclassFetchMode: join
openjpa.jdbc.UpdateManager: default
openjpa.jdbc.SynchronizeMappings: false
openjpa.NontransactionalRead: true
openjpa.QueryCompilationCache: true
openjpa.MaxFetchDepth: -1
openjpa.RetainState: true
openjpa.DynamicDataStructs: false
openjpa.BrokerFactory: jdbc
openjpa.WriteLockLevel: write
openjpa.ManagedRuntime:
org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl$TxMgrProvider
openjpa.jdbc.EagerFetchMode: parallel
openjpa.RestoreState: immutable
openjpa.jdbc.SchemaFactory: dynamic
openjpa.LockManager: version
openjpa.BrokerImpl: default
openjpa.NontransactionalWrite: true
openjpa.MetaDataRepository: default
openjpa.Log: true(DefaultLevel=TRACE)
openjpa.jdbc.ResultSetType: forward-only
openjpa.AutoDetach:
openjpa.ConnectionRetainMode: on-demand
openjpa.SavepointManager: in-mem
openjpa.jdbc.DBDictionary: derby
openjpa.Optimistic: true
openjpa.ConnectionFactoryMode: managed
openjpa.Sequence: table
openjpa.FetchGroups: default
openjpa.jdbc.Schemas:
openjpa.Id: ode-dao
openjpa.OrphanedKeyAction: log
openjpa.FlushBeforeQueries: true
openjpa.AutoClear: datastore
openjpa.Compatibility: default
openjpa.DetachState: loaded
openjpa.jdbc.LRSSize: query
openjpa.Multithreaded: false
openjpa.FetchBatchSize: -1
openjpa.jdbc.SQLFactory: default
openjpa.IgnoreChanges: false
openjpa.jdbc.MappingDefaults: jpa
openjpa.TransactionMode: local
openjpa.RetryClassRegistration: false
openjpa.jdbc.FetchDirection: forward
openjpa.ClassResolver: default
openjpa.LockTimeout: -1
openjpa.DataCacheTimeout: -1
openjpa.QueryCache: true
openjpa.jdbc.DriverDataSource: simple
openjpa.jdbc.TransactionIsolation: default

Re: OpenJPA Transaction configuration

2007-02-28 Thread Matthieu Riou

Thanks! But shouldn't I worry about the fact that a brand new instance is
detached? I could be wrong but it looks like it's more a symptom of
something wrong in my configuration, no?

On 2/28/07, Pinaki Poddar [EMAIL PROTECTED] wrote:


  instead of _em.persist(ret);
try
  _em.merge(ret);

as ret is detached instance rather than new.



Pinaki Poddar
BEA Systems
415.402.7317


-Original Message-
From: Matthieu Riou [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 28, 2007 6:29 PM
To: open-jpa-dev@incubator.apache.org
Subject: OpenJPA  Transaction configuration

Hi,

I'm going back at the OpenJPA implementation for the Apache ODE project
and am still having problems with the setup. Whan I try to persist a new
object I get an exception Attempt to persist detached object. I guess
the when I instantiate my object OpenJPA can't locate its transactional
context or something related therefore assuming that the object is
instantiated outside of any persistent context.

Here is the code that creates the EntityManagerFactory:

HashMapString, Object propMap = new HashMapString,Object();
propMap.put(openjpa.Log, DefaultLevel=TRACE);
propMap.put(openjpa.jdbc.DBDictionary, 
org.apache.openjpa.jdbc.sql.DerbyDictionary);
propMap.put(openjpa.ManagedRuntime, new TxMgrProvider());
propMap.put(openjpa.ConnectionFactory, _ds);
propMap.put(openjpa.ConnectionFactoryMode, managed);
propMap.put(openjpa.Log, DefaultLevel=TRACE);
_emf = Persistence.createEntityManagerFactory(ode-dao,
propMap);

And here is my object instantiation code:

ProcessDAOImpl ret = new
ProcessDAOImpl(pid,type,guid,this,version);
System.out.println(detached  +
((PersistenceCapable)ret).pcIsDetached());
_em.persist(ret);

My little debugging statement outputs true. I've reproduced the full
log below. I've also encapsulated to transaction manager and the
transaction to check whether OpenJPA was getting the transaction and
registering a synchronizer properly. It seems to be doing so (the log
statements are just a couple lines above the '.'). I've removed all
the mapping logs just to avoid making this too lengthy.

Any idea of what the problem could be? I'm kind of stuck on this as it's
hard to debug the enhanced code that gets called when I instantiate my
process object.

DEBUG - ODEMessageReceiver.receive(47) | Received message for
helloWorld.hello DEBUG - ODEService.onAxisMessageExchange(96) | Starting
transaction.
DEBUG - BpelEngineImpl.route(237) | Routed: svcQname {
http://ode/bpel/unit-test.wsdl}HelloService -- BpelProcess[{
http://ode/bpel/unit-test}HelloWorld2-1]
29603  ode-dao  INFO   [http-8080-Processor25] openjpa.Runtime -
Starting
OpenJPA 0.9.7-incubating-SNAPSHOT
29604  ode-dao  TRACE  [http-8080-Processor25] openjpa.Runtime -
Properties:
openjpa.EntityManagerFactory: default
openjpa.DataCache: false
openjpa.MetaDataFactory: jpa(Types=
org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl
;org.apache.ode.dao.jpa.CorrelationSetDAOImpl;org.apache.ode.dao.jpa.Cor
relatorDAOImpl;org.apache.ode.dao.jpa.EventDAOImpl;org.apache.ode.dao.jp
a.FaultDAOImpl;org.apache.ode.dao.jpa.MessageDAOImpl;org.apache.ode.dao.
jpa.MessageExchangeDAOImpl;org.apache.ode.dao.jpa.MessageRouteDAOImpl;or
g.apache.ode.dao.jpa.PartnerLinkDAOImpl;org.apache.ode.dao.jpa.ProcessDA
OImpl;org.apache.ode.dao.jpa.ProcessInstanceDAOImpl;org.apache.ode.dao.j
pa.ScopeDAOImpl;org.apache.ode.dao.jpa.XmlDataDAOImpl)
openjpa.InverseManager: false
openjpa.ReadLockLevel: read
openjpa.DataCacheManager: default
openjpa.jdbc.SubclassFetchMode: join
openjpa.jdbc.UpdateManager: default
openjpa.jdbc.SynchronizeMappings: false
openjpa.NontransactionalRead: true
openjpa.QueryCompilationCache: true
openjpa.MaxFetchDepth: -1
openjpa.RetainState: true
openjpa.DynamicDataStructs: false
openjpa.BrokerFactory: jdbc
openjpa.WriteLockLevel: write
openjpa.ManagedRuntime:
org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl$TxMgrProvider
openjpa.jdbc.EagerFetchMode: parallel
openjpa.RestoreState: immutable
openjpa.jdbc.SchemaFactory: dynamic
openjpa.LockManager: version
openjpa.BrokerImpl: default
openjpa.NontransactionalWrite: true
openjpa.MetaDataRepository: default
openjpa.Log: true(DefaultLevel=TRACE)
openjpa.jdbc.ResultSetType: forward-only
openjpa.AutoDetach:
openjpa.ConnectionRetainMode: on-demand
openjpa.SavepointManager: in-mem
openjpa.jdbc.DBDictionary: derby
openjpa.Optimistic: true
openjpa.ConnectionFactoryMode: managed
openjpa.Sequence: table
openjpa.FetchGroups: default
openjpa.jdbc.Schemas:
openjpa.Id: ode-dao
openjpa.OrphanedKeyAction: log
openjpa.FlushBeforeQueries: true
openjpa.AutoClear: datastore
openjpa.Compatibility: default
openjpa.DetachState: loaded
openjpa.jdbc.LRSSize: query
openjpa.Multithreaded: false
openjpa.FetchBatchSize: -1
openjpa.jdbc.SQLFactory: default
openjpa.IgnoreChanges: false
openjpa.jdbc.MappingDefaults: jpa
openjpa.TransactionMode: local
openjpa.RetryClassRegistration

RE: OpenJPA Transaction configuration

2007-02-28 Thread Patrick Linskey
Can you post the source for ProcessDAOImpl? Also, are there any other
OpenJPA properties in your configuration? Finally, I'm assuming that
you're using a somewhat-current 0.9.7-SNAPSHOT. Correct me if I'm wrong.

 But shouldn't I worry about the fact that a brand new 
 instance is detached? I could be wrong but it looks 
 like it's more a symptom of

I believe that you should. I think I remember reading something about
this recently, but I don't remember the details. My suspicion is that
you don't have an @Version field, and you're using the default detach
manager. IIRC, this combination leaves OpenJPA with no way to detect a
detached object vs. a new object, and we default to detached. I thought
that we had improved the docs around this at the least; certainly, it'd
be good to figure out your particulars and make sure that this is
clearer for others.

(IIRC, the default detach manager uses a heuristic on the value in the
version field to determine whether an instance is new or detached.
OpenJPA supports more flexible detach managers that can do fun things
like providing useful errors when attempting to navigate past the end of
a detached object graph, and fine-grained tracking of changes made while
detached. But it's not serialization-compatible with the unenhanced
code, meaning that you need to put the enhanced classes into your client
tier, which I think that we decided was a bad default.)

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

___
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

 -Original Message-
 From: Matthieu Riou [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, February 28, 2007 7:50 PM
 To: Pinaki Poddar
 Cc: open-jpa-dev@incubator.apache.org
 Subject: Re: OpenJPA  Transaction configuration
 
 Thanks! But shouldn't I worry about the fact that a brand new 
 instance is
 detached? I could be wrong but it looks like it's more a symptom of
 something wrong in my configuration, no?
 
 On 2/28/07, Pinaki Poddar [EMAIL PROTECTED] wrote:
 
instead of _em.persist(ret);
  try
_em.merge(ret);
 
  as ret is detached instance rather than new.
 
 
 
  Pinaki Poddar
  BEA Systems
  415.402.7317
 
 
  -Original Message-
  From: Matthieu Riou [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, February 28, 2007 6:29 PM
  To: open-jpa-dev@incubator.apache.org
  Subject: OpenJPA  Transaction configuration
 
  Hi,
 
  I'm going back at the OpenJPA implementation for the Apache 
 ODE project
  and am still having problems with the setup. Whan I try to 
 persist a new
  object I get an exception Attempt to persist detached 
 object. I guess
  the when I instantiate my object OpenJPA can't locate its 
 transactional
  context or something related therefore assuming that the object is
  instantiated outside of any persistent context.
 
  Here is the code that creates the EntityManagerFactory:
 
  HashMapString, Object propMap = new 
 HashMapString,Object();
  propMap.put(openjpa.Log, DefaultLevel=TRACE);
  propMap.put(openjpa.jdbc.DBDictionary, 
  org.apache.openjpa.jdbc.sql.DerbyDictionary);
  propMap.put(openjpa.ManagedRuntime, new TxMgrProvider());
  propMap.put(openjpa.ConnectionFactory, _ds);
  propMap.put(openjpa.ConnectionFactoryMode, managed);
  propMap.put(openjpa.Log, DefaultLevel=TRACE);
  _emf = Persistence.createEntityManagerFactory(ode-dao,
  propMap);
 
  And here is my object instantiation code:
 
  ProcessDAOImpl ret = new
  ProcessDAOImpl(pid,type,guid,this,version);
  System.out.println(detached  +
  ((PersistenceCapable)ret).pcIsDetached());
  _em.persist(ret);
 
  My little debugging statement outputs true. I've 
 reproduced the full
  log below. I've also encapsulated to transaction manager and the
  transaction to check whether OpenJPA was getting the transaction and
  registering a synchronizer properly. It seems to be doing 
 so (the log
  statements are just a couple lines above the '.'). I've 
 removed all
  the mapping logs just to avoid making this too lengthy.
 
  Any idea of what the problem could be? I'm kind of stuck on 
 this as it's
  hard to debug the enhanced code that gets called when I 
 instantiate my
  process object.
 
  DEBUG - ODEMessageReceiver.receive(47) | Received message for
  helloWorld.hello DEBUG - 
 ODEService.onAxisMessageExchange(96) | Starting
  transaction.
  DEBUG - BpelEngineImpl.route(237) | Routed: svcQname {
  http://ode/bpel/unit-test.wsdl}HelloService -- BpelProcess

Re: OpenJPA Transaction configuration

2007-02-28 Thread Matthieu Riou

Here is a link to the source (and no version field):

http://svn.apache.org/repos/asf/incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java

How can I try to change the default detach manager? Which one should I use
instead?

Thanks!
Matthieu

On 2/28/07, Patrick Linskey [EMAIL PROTECTED] wrote:


Can you post the source for ProcessDAOImpl? Also, are there any other
OpenJPA properties in your configuration? Finally, I'm assuming that
you're using a somewhat-current 0.9.7-SNAPSHOT. Correct me if I'm wrong.

 But shouldn't I worry about the fact that a brand new
 instance is detached? I could be wrong but it looks
 like it's more a symptom of

I believe that you should. I think I remember reading something about
this recently, but I don't remember the details. My suspicion is that
you don't have an @Version field, and you're using the default detach
manager. IIRC, this combination leaves OpenJPA with no way to detect a
detached object vs. a new object, and we default to detached. I thought
that we had improved the docs around this at the least; certainly, it'd
be good to figure out your particulars and make sure that this is
clearer for others.

(IIRC, the default detach manager uses a heuristic on the value in the
version field to determine whether an instance is new or detached.
OpenJPA supports more flexible detach managers that can do fun things
like providing useful errors when attempting to navigate past the end of
a detached object graph, and fine-grained tracking of changes made while
detached. But it's not serialization-compatible with the unenhanced
code, meaning that you need to put the enhanced classes into your client
tier, which I think that we decided was a bad default.)

-Patrick

--
Patrick Linskey
BEA Systems, Inc.

___
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

 -Original Message-
 From: Matthieu Riou [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 28, 2007 7:50 PM
 To: Pinaki Poddar
 Cc: open-jpa-dev@incubator.apache.org
 Subject: Re: OpenJPA  Transaction configuration

 Thanks! But shouldn't I worry about the fact that a brand new
 instance is
 detached? I could be wrong but it looks like it's more a symptom of
 something wrong in my configuration, no?

 On 2/28/07, Pinaki Poddar [EMAIL PROTECTED] wrote:
 
instead of _em.persist(ret);
  try
_em.merge(ret);
 
  as ret is detached instance rather than new.
 
 
 
  Pinaki Poddar
  BEA Systems
  415.402.7317
 
 
  -Original Message-
  From: Matthieu Riou [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, February 28, 2007 6:29 PM
  To: open-jpa-dev@incubator.apache.org
  Subject: OpenJPA  Transaction configuration
 
  Hi,
 
  I'm going back at the OpenJPA implementation for the Apache
 ODE project
  and am still having problems with the setup. Whan I try to
 persist a new
  object I get an exception Attempt to persist detached
 object. I guess
  the when I instantiate my object OpenJPA can't locate its
 transactional
  context or something related therefore assuming that the object is
  instantiated outside of any persistent context.
 
  Here is the code that creates the EntityManagerFactory:
 
  HashMapString, Object propMap = new
 HashMapString,Object();
  propMap.put(openjpa.Log, DefaultLevel=TRACE);
  propMap.put(openjpa.jdbc.DBDictionary, 
  org.apache.openjpa.jdbc.sql.DerbyDictionary);
  propMap.put(openjpa.ManagedRuntime, new TxMgrProvider());
  propMap.put(openjpa.ConnectionFactory, _ds);
  propMap.put(openjpa.ConnectionFactoryMode, managed);
  propMap.put(openjpa.Log, DefaultLevel=TRACE);
  _emf = Persistence.createEntityManagerFactory(ode-dao,
  propMap);
 
  And here is my object instantiation code:
 
  ProcessDAOImpl ret = new
  ProcessDAOImpl(pid,type,guid,this,version);
  System.out.println(detached  +
  ((PersistenceCapable)ret).pcIsDetached());
  _em.persist(ret);
 
  My little debugging statement outputs true. I've
 reproduced the full
  log below. I've also encapsulated to transaction manager and the
  transaction to check whether OpenJPA was getting the transaction and
  registering a synchronizer properly. It seems to be doing
 so (the log
  statements are just a couple lines above the '.'). I've
 removed all
  the mapping logs just to avoid making this too lengthy.
 
  Any idea of what the problem could be? I'm kind of stuck on
 this as it's
  hard to debug the enhanced code that gets called when