Kalpa Welivitigoda | 20 Jul 20:14 2014
Picon

Create H2 database even before adding records

Hi,

I am developing an application with H2 in memory database.

The issue is that the table is created only after I add a record. Before
that, if I search for a record it says that the table is not found. I want
to create the table at the time the application starts rather than waiting
for a record to be added. Is there any property that serves this
requirement.

Following is the content of persistence.xml,

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
    <persistence-unit name="rest-jpa">

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>java:/comp/env/jdbc/restDB</jta-data-source>
        <class>org.wso2.as.ee.Student</class>
        <properties>
            <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
        </properties>
    </persistence-unit>
</persistence>

I have the datasource defined in context.xml as follows,

<?xml version="1.0" encoding="UTF-8"?>
<Context>
(Continue reading)

artaxerxe | 15 Jul 13:39 2014
Picon

Problems with OpenJPA when deploying in Apache Servicemix and Spring. (OSGi environment)

Hello everyone. For a time I'm striving with a problem that I have with
OpenJPA. I'm trying to deploy my bundle that contains OpenJPA entities in an
OSGi compliant server, namely Apache Servicemix. I'm accessing the OpenJPA
entities using Spring. The problem is that when I make the deployment for my
bundle, I get this error:

openjpa.Runtime - An error occurred while registering a ClassTransformer
with PersistenceUnitInfo: name 'openjpa-test', root URL [bundle://240.0:1].
The error is logged along with this warning. Load-time class transformation
will not be available.<openjpa-2.3.0-r422266:1540826 nonfatal general error>
org.apache.openjpa.util.GeneralException: Resource does not exist:
bundle://240.0:1
	at
org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:635)
	at
org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNamesInternal(MetaDataRepository.java:1478)
	at
org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNames(MetaDataRepository.java:1470)
	at
org.apache.openjpa.enhance.PCClassFileTransformer.<init>(PCClassFileTransformer.java:103)
	at
org.apache.openjpa.enhance.PCClassFileTransformer.<init>(PCClassFileTransformer.java:67)
	at
org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.<init>(PersistenceProviderImpl.java:284)
	at
org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.<init>(PersistenceProviderImpl.java:266)
	at
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:169)
	at
org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
(Continue reading)

Mansour Al Akeel | 12 Jul 13:03 2014
Picon

Problem creating table with <at> IdClass an foreign keys constraints

Hello all,

To demonstrate the problem and make it easier to get help, I have created
an application here:

https://github.com/malakeel/jpa-id-class-example

This application is to create tables with constrains from JPA entities.
Tables are created, however I am unable to generate
the foreign key constrains.

Here's the description of the entities. We have the Services Entity, with
fields relates the service provider to the
client, and the service type. The Service Entity has its primary keys
(service provider and client). Both are Person(s).

When this application is run using  <at> IdClass(ServicePK.class), I get the
exception:

<openjpa-2.3.0-r422266:1540826 fatal user error>
org.apache.openjpa.persistence.ArgumentException: The id class specified by
type "class com.example.Service" does not match the primary key fields of
the class.  Make sure your identity class has the same primary keys as your
persistent type, including pk field types. Mismatched property: "client"
    at
org.apache.openjpa.meta.ClassMetaData.validateAppIdClassPKs(ClassMetaData.java:2225)
    at
org.apache.openjpa.meta.ClassMetaData.validateAppIdClass(ClassMetaData.java:2099)
    at
org.apache.openjpa.meta.ClassMetaData.validateIdentity(ClassMetaData.java:2035)
(Continue reading)

David Minor | 11 Jul 02:09 2014
Picon

Re: Avoiding N+1 on collection in recursive relation

The problem seems to be that in org.apache.openjpa.jdbc.sql.SelectImpl, as
it's building up the necessary select statements, it keeps a HashSet of the
fields that already have eager selects created for them, and doesn't create
another eager select if one already exists for that particular field.

So, when requesting a particular entity of class A { List<B> bs; List<A>
children; }, OpenJPA creates parallel eager selects for 'A.bs' and
'A.children', but then as it examines 'children', it doesn't create a
parallel eager select for their 'bs' since the field 'A.bs' already has an
eager select for it according to the HashSet.

Later as it's loading the data it uses individual statements to get the
missing data.

There's a comment in JDBCStoreManager prior to the call to
createEagerSelects():

// create all our eager selects so that those fields are reserved
// and cannot be reused during the actual eager select process,
// preventing infinite recursion

which makes sense, since you wouldn't necessarily want to select the
children's children's children, etc. But in this case, it seems to prevent
efficient selection of desired fields.

I believe this is also the cause of the problem reported in
https://issues.apache.org/jira/browse/OPENJPA-2299

In that case you have class A { List<B> list1; List<B> list2; }, and eager
selects are created for list1's collection fields but not list2 (since both
(Continue reading)

Rick Curtis | 10 Jul 14:58 2014
Picon

Re: Avoiding N+1 on collection in recursive relation

David -

It seems like this question has been asked numerous times on this mailing
list and no one has come up with a good answer. I too don't have an answer,
but if you come up with anything please post back to the list.

Thanks,
Rick

On Tue, Jul 8, 2014 at 6:56 PM, David Minor <daveminor@...> wrote:

> I have an entity (A) that has a recursive OneToMany relation with itself
> (children). A also has a OneToMany relation to entity B.
>
> Whenever A is fetched, the queries to fetch B for entity A and its children
> are all separate queries.
>
> Is there any way to avoid this?
>
> --
> _____________
> David Minor
>

--

-- 
*Rick Curtis*
michaelwiles | 10 Jul 14:16 2014
Picon

OrderColumn not working in one to many with mappedBy

I have a "regular" one to many. It has an OrderColumn annotation.

This mapping when I run my tests I see the order column called
elementsWithOrder_ORDER getting updated.

However, the following mapping (with a mappedBy) I don't see the order
column being updated...

The mappedby field looks as follows:

If you switch the persistence provider to Eclipselink the tests pass.

I have created a  github project
<https://github.com/michaelwiles/OpenJpaBugs>   to demonstrate this.

I'm assuming this is in fact a bug because surely using "mappedBy" shjould
not stop ordered lists from working.

Btw, this is run on OpenJPA 2.3.0

--
View this message in context: http://openjpa.208410.n2.nabble.com/OrderColumn-not-working-in-one-to-many-with-mappedBy-tp7586930.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

David Minor | 9 Jul 01:56 2014
Picon

Avoiding N+1 on collection in recursive relation

I have an entity (A) that has a recursive OneToMany relation with itself
(children). A also has a OneToMany relation to entity B.

Whenever A is fetched, the queries to fetch B for entity A and its children
are all separate queries.

Is there any way to avoid this?

--

-- 
_____________
David Minor
Pawel Veselov | 6 Jul 06:20 2014
Picon

Something is missing in OpenJPA 2.3.0 distribution

Hi.

Something seems to be missing from the libraries in the OpenJPA distro.
I don't normally use the "all" jar, and without it, the enhancer fails with
class not found of org/apache/xbean/asm4/ClassVisitor.class. The class is
there in "all" jar, but not in any of the library jars...
Pawel Veselov | 6 Jul 05:58 2014
Picon

OpenJPA 2.3.0 packages Derby?

Hi.

I see that 2.3.0 has a packaged derby jar (10.8.2.2)

I was wondering what the reason is, and can I yank it out even if I'm not
using Derby (in my deployment, derby.jar is deployed at application server
level, and openjpa is packaged along .war file)

Thank you,
  Pawel.
Boblitz John | 27 Jun 12:02 2014

Postgres HStore implementation

Hello,

I'm trying to get the Postgres HStore type to work and play nice in openJPA 2.3 and I've hit a wall ...

Are there any examples around / has anyone done this before and would be willing to share?`

Thanks & Best Regards,

John
Rupert Smith | 26 Jun 14:54 2014

Cannot use local transaction during installDBDictionary.

I am getting this error during installDBDictionary:

Caused by: java.sql.SQLException: could not use local transaction commit in
a global transaction
        at
oracle.jdbc.driver.PhysicalConnection.disallowGlobalTxnMode(PhysicalConnection.java:6825)
        at
oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3812)
        at
oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3857)
        at
oracle.jdbc.OracleConnectionWrapper.commit(OracleConnectionWrapper.java:140)
        at
org.tranql.connector.jdbc.ManagedXAConnection.localTransactionCommit(ManagedXAConnection.java:102)
        at
org.tranql.connector.AbstractManagedConnection$LocalTransactionImpl.commit(AbstractManagedConnection.java:199)
        at
org.tranql.connector.jdbc.ConnectionHandle.setAutoCommit(ConnectionHandle.java:160)
        at
org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:167)
        at
org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:167)
        at
org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.setAutoCommit(ConfiguringConnectionDecorator.java:117)
        at
org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.<init>(ConfiguringConnectionDecorator.java:111)
        at
org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator.decorate(ConfiguringConnectionDecorator.java:93)
        at
org.apache.openjpa.lib.jdbc.DecoratingDataSource.decorate(DecoratingDataSource.java:99)
(Continue reading)


Gmane