Re: Slice and connection pools

2011-08-02 Thread Rick Curtis
What is the error that you are seeing?

On Mon, Aug 1, 2011 at 8:03 PM, RICHARD LUONG rlu...@gmail.com wrote:

 Hi,

 Does Slice support using a connection pool?  I was able to get the
 connection pool working when not using Slice with the following
 persistence-unit:

persistence-unit name=test transaction-type=RESOURCE_LOCAL
provider
org.apache.openjpa.persistence.PersistenceProviderImpl
/provider

properties
 property name=openjpa.ConnectionProperties
value=DriverClassName=com.mysql.jdbc.Driver,
  Url=jdbc:mysql://url:3306/test,
  MaxActive=300,
  TestOnBorrow=true,
  Username=user,
  Password=password/
property name=openjpa.ConnectionDriverName
value=org.apache.commons.dbcp.BasicDataSource/
/properties
 /persistence-unit

 However, I got an error when attempting to use it in Slice, with the
 following:

persistence-unit name=test2 transaction-type=RESOURCE_LOCAL
provider
org.apache.openjpa.persistence.PersistenceProviderImpl
/provider

 properties
  property name=openjpa.Log value=Runtime=TRACE, SQL=TRACE,
 DefaultLevel=TRACE, Tool=TRACE/
 property name=openjpa.BrokerFactory value=slice/
  property name=openjpa.slice.Names   value=slice1/
 property name=openjpa.slice.Master  value=slice1/
  !-- Lenient: Allows DB to continue, even when one slice is unavailable.
 --
 property name=openjpa.slice.Lenient value=true/

 property name=openjpa.ConnectionDriverName
  value=org.apache.commons.dbcp.BasicDataSource/

 property name=openjpa.slice.slice1.ConnectionProperties
value=DriverClassName=com.mysql.jdbc.Driver,
  Url=jdbc:mysql://url:3306/test,
  MaxActive=300,
  TestOnBorrow=true,
  Username=user,
  Password=password/
  property name=openjpa.slice.DistributionPolicy

 value=com.service.openjpa.DistributeByInstitutionPolicy/
 property name=openjpa.slice.FinderTargetPolicy
   value=com.service.openjpa.ShardFinderTargetPolicy/
 property name=openjpa.slice.ReplicatedTypes
   value=com/

 . property name=openjpa.QueryCache value=false/
  property name=openjpa.DataCache value=false/
 . property name=openjpa.QueryCompilationCache value=false/
  property name=openjpa.jdbc.QuerySQLCache value=false/
 property name=openjpa.jdbc.FinderCache value=false/
  property name=openjpa.DetachState
 value=loaded(DetachedStateField=false)/
  /properties
/persistence-unit


 Am I missing something in my configuration or is this just something that
 is
 not supported by Slice?  If it's not supported, are there any recommended
 alternatives?

 Thanks,
 Richard.




-- 
*Rick Curtis*


Version of all children is incremented in OneToMany when merging parent entity

2011-08-02 Thread M. Walter
I have a OneToMany relationship defined like this:

@Entity
Parent {
@OneToMany(mappedBy = parent, fetch = FetchType.LAZY, cascade = {
CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE})
private ListChild childList;
// ...
@Version
private int version;
}

@Entity
Child {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = PARENT_ID)
private Parent parent;
// ...
@Version
private int version;
}

Now when I change ONE of the child elements and do a merge by executing
em.merge(parent), the version of ALL children is incremented by one! I
expected that the version of the changed child is incremented only. Is this
a bug? I could not find anything about this behaviour in the
documentation...

--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Version-of-all-children-is-incremented-in-OneToMany-when-merging-parent-entity-tp6645128p6645128.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Slice and connection pools

2011-08-02 Thread RICHARD LUONG
I'm getting the following error:

Caused by: openjpa-2.1.0-r422266:1071316 nonfatal user error
org.apache.openjpa.persistence.ArgumentException: No slices are configured
or available
 at
org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.createDistributedDataStore(DistributedJDBCConfigurationImpl.java:363)
at
org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.createConnectionFactory(DistributedJDBCConfigurationImpl.java:626)
 at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)
at
org.apache.openjpa.jdbc.meta.MappingDefaultsImpl.setConfiguration(MappingDefaultsImpl.java:878)
 at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:486)
at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:443)
 at
org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
 at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getMappingDefaultsInstance(JDBCConfigurationImpl.java:706)
at
org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.newSlice(DistributedJDBCConfigurationImpl.java:467)
 at
org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.fromProperties(DistributedJDBCConfigurationImpl.java:618)
at
org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(MapConfigurationProvider.java:85)
 at
org.apache.openjpa.persistence.PersistenceProductDerivation$ConfigurationProviderImpl.setInto(PersistenceProductDerivation.java:698)
at
org.apache.openjpa.slice.jdbc.DistributedJDBCBrokerFactory.newInstance(DistributedJDBCBrokerFactory.java:56)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:131)
at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:65)
 at
org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:151)
at
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:191)
 at
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:66)
at
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
 at
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
 at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 130 more

On Tue, Aug 2, 2011 at 6:29 AM, Rick Curtis curti...@gmail.com wrote:

 What is the error that you are seeing?

 On Mon, Aug 1, 2011 at 8:03 PM, RICHARD LUONG rlu...@gmail.com wrote:

  Hi,
 
  Does Slice support using a connection pool?  I was able to get the
  connection pool working when not using Slice with the following
  persistence-unit:
 
 persistence-unit name=test transaction-type=RESOURCE_LOCAL
 provider
 org.apache.openjpa.persistence.PersistenceProviderImpl
 /provider
 
 properties
  property name=openjpa.ConnectionProperties
 value=DriverClassName=com.mysql.jdbc.Driver,
   Url=jdbc:mysql://url:3306/test,
   MaxActive=300,
   TestOnBorrow=true,
   Username=user,
   Password=password/
 property name=openjpa.ConnectionDriverName
 value=org.apache.commons.dbcp.BasicDataSource/
 /properties
  /persistence-unit
 
  However, I got an error when attempting to use it in Slice, with the
  following:
 
 persistence-unit name=test2 transaction-type=RESOURCE_LOCAL
 provider
 org.apache.openjpa.persistence.PersistenceProviderImpl
 /provider
 
  properties
   property name=openjpa.Log value=Runtime=TRACE, SQL=TRACE,
  DefaultLevel=TRACE, Tool=TRACE/
  property name=openjpa.BrokerFactory value=slice/
   property name=openjpa.slice.Names   value=slice1/
  property name=openjpa.slice.Master  value=slice1/
   !-- Lenient: Allows DB to continue, even when one slice is unavailable.
  --
  property name=openjpa.slice.Lenient value=true/
 
  property name=openjpa.ConnectionDriverName
   value=org.apache.commons.dbcp.BasicDataSource/
 
  property name=openjpa.slice.slice1.ConnectionProperties
 value=DriverClassName=com.mysql.jdbc.Driver,
   

Re: Native SQL Query

2011-08-02 Thread lspasam
Any updates? Has this been tested yet?

On 06/14/2011 02:37 PM, Pinaki Poddar [via OpenJPA] wrote:
 If possible, try revision 1135806 from trunk.

 I have committed a draft version that would execute SQL in Slice. I 
 have not tested it and I have concerns about sorting etc.

 If possible, let me know whether it gets you out of NPE.
 Also check for ORDER By or SUM() type support which perhaps will 
 simply not work.
 Pinaki


 
 If you reply to this email, your message will be added to the 
 discussion below:
 http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6476092.html 

 To unsubscribe from Native SQL Query, click here 
 http://openjpa.208410.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=6432918code=bGVzQGVkZWxlbWVudHMuY29tfDY0MzI5MTh8LTE3NTY0MTAyMjc=.
  



-- 
Les Pasamonte
Engineering
Edelements Inc.



--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6645883.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Native SQL Query

2011-08-02 Thread Pinaki Poddar
 Any updates? Has this been tested yet?
As a brave user of Open Source software, you will be testing it, I hoped :)
Of course, It is checked-in with some degree of testing. 


-
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6645971.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Audit log with OpenJPA

2011-08-02 Thread Pinaki Poddar
Hi Bengt,
  It is possible (with some effort :) to offer a different POJO y that holds
the original state of a managed POJO x *when* x entered a persistence
context. But y can not be managed by the same context, because x is already
present in that context. So y will be essentially an unmanaged (not even
detached) instance. 

  Because of that conceptual dilemma, I went for the option of offering only
the dirty field values. It is also possible to offer all field values. 

-
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Audit-log-with-OpenJPA-tp6557932p6645998.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Native SQL Query

2011-08-02 Thread lspasam
I just checked out, built and ran the code against revision 1135806.  
Error is the same. Attached:

Caused by: java.lang.NullPointerException
 at 
org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:154)
 at 
org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:672)
 at 
org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:640)
 at 
org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620)
 ... 51 more

Please advise.

Thanks!

On 08/02/2011 11:41 AM, Pinaki Poddar [via OpenJPA] wrote:
  Any updates? Has this been tested yet?
 As a brave user of Open Source software, you will be testing it, I 
 hoped :)
 Of course, It is checked-in with some degree of testing.
 Pinaki Poddar
 Chair, Apache OpenJPA Project


 
 If you reply to this email, your message will be added to the 
 discussion below:
 http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6645971.html 

 To unsubscribe from Native SQL Query, click here 
 http://openjpa.208410.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=6432918code=bGVzQGVkZWxlbWVudHMuY29tfDY0MzI5MTh8LTE3NTY0MTAyMjc=.
  



--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6646144.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Native SQL Query

2011-08-02 Thread Pinaki Poddar
Hi,
  I just cross checked with a native SQL query on Slice. It does run. 
Though the new addition lacked thorough testing, I would not expect the
error you have reported provided the new changes are applied in your
environment. 

To ensure that the change is available in your environment, please do the
following:

1. $ java -jar /path/to/openjpa.jar
this will print the SVN reversion number openjpa is built with

2. Check whether following class is present in the distribution (because
this is the newly added class)
org.apache.openjpa.slice.jdbc.DistributedSQLStoreQuery


-
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Native-SQL-Query-tp6432918p6646315.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Slice and connection pools

2011-08-02 Thread RICHARD LUONG
Ok, I've found a workaround.  The code seems to be failing because it cannot
determine the DBDictionary to use.  It uses the ConnectionURL (null) and the
ConnectionDriverName (which points to the pool) to determine the
DBDictionary.  Once that fails, it attempts to connect to the database to
try and determine the dictionary.  It tries to grab a slice, but the
collection of slices is empty, since this is all happening during the
process of adding the first slice.  With no slice, it cannot connect and
throws no slices configured exception.

The workaround that I'm doing is explicitly setting the DBDictionary with
the following in my persistence-unit properties:
property name=openjpa.jdbc.DBDictionary value=mysql/

Hope that helps anyone else that runs into the same issue.

Richard.

On Tue, Aug 2, 2011 at 8:51 AM, RICHARD LUONG rlu...@gmail.com wrote:

 I'm getting the following error:

 Caused by: openjpa-2.1.0-r422266:1071316 nonfatal user error
 org.apache.openjpa.persistence.ArgumentException: No slices are configured
 or available
  at
 org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.createDistributedDataStore(DistributedJDBCConfigurationImpl.java:363)
 at
 org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.createConnectionFactory(DistributedJDBCConfigurationImpl.java:626)
  at
 org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)
 at
 org.apache.openjpa.jdbc.meta.MappingDefaultsImpl.setConfiguration(MappingDefaultsImpl.java:878)
  at
 org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:486)
 at
 org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:443)
  at
 org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104)
 at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
  at
 org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getMappingDefaultsInstance(JDBCConfigurationImpl.java:706)
 at
 org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.newSlice(DistributedJDBCConfigurationImpl.java:467)
  at
 org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.fromProperties(DistributedJDBCConfigurationImpl.java:618)
 at
 org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(MapConfigurationProvider.java:85)
  at
 org.apache.openjpa.persistence.PersistenceProductDerivation$ConfigurationProviderImpl.setInto(PersistenceProductDerivation.java:698)
 at
 org.apache.openjpa.slice.jdbc.DistributedJDBCBrokerFactory.newInstance(DistributedJDBCBrokerFactory.java:56)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
  at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:131)
 at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:65)
  at
 org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:151)
 at
 org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:191)
  at
 org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:66)
 at
 org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
  at
 org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
 at
 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
  at
 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
 ... 130 more

 On Tue, Aug 2, 2011 at 6:29 AM, Rick Curtis curti...@gmail.com wrote:

 What is the error that you are seeing?

 On Mon, Aug 1, 2011 at 8:03 PM, RICHARD LUONG rlu...@gmail.com wrote:

  Hi,
 
  Does Slice support using a connection pool?  I was able to get the
  connection pool working when not using Slice with the following
  persistence-unit:
 
 persistence-unit name=test transaction-type=RESOURCE_LOCAL
 provider
 org.apache.openjpa.persistence.PersistenceProviderImpl
 /provider
 
 properties
  property name=openjpa.ConnectionProperties
 value=DriverClassName=com.mysql.jdbc.Driver,
   Url=jdbc:mysql://url:3306/test,
   MaxActive=300,
   TestOnBorrow=true,
   Username=user,
   Password=password/
 property name=openjpa.ConnectionDriverName
 value=org.apache.commons.dbcp.BasicDataSource/
 /properties