Re: Persistence.xml configuration, OpenJPA not mapping entities to mysql db

2013-10-17 Thread Michael Dick
OpenJPA is in the process of creating the tables when an error occurs. It
looks like a syntax error from the database over the AUTO_INCREMENT
keyword. I didn't find any hits on the sql state and error code though.

Are there any chained exceptions? A nested SQLException might have a more
helpful message.

I did try the SQL statement on a local copy of MySQL and I was able to
create the table manually, so I don't think there are any syntax errors. As
a last resort you could try running the SQL manually too, and see if it has
trouble with any other tables.

-mike




On Thu, Oct 17, 2013 at 7:33 AM, wlad  wrote:

> Hi,
> I am (new to JEE) working with: EJB3, Apache TomEE plus 1.5.2, openjpa as
> persistence provider, MySQL database,  Eclipse IDE.
> I'm trying to run simple EJB with JPA example but getting this error:
>
> "
> org.apache.openjpa.persistence.PersistenceException: unexpected token:
> AUTO_INCREMENT {stmnt 15634609 CREATE TABLE gorivo (gorivo_id INTEGER NOT
> NULL AUTO_INCREMENT, gorivo_tip VARCHAR(255) NOT NULL, PRIMARY KEY
> (gorivo_id), UNIQUE U_GORIVO_GORIVO_ID (gorivo_id)) ENGINE = innodb}
> [code=-5581, state=42581]
> at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:559)
> at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:455)
> at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:160)
> at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:164)
> at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:122)
> at
>
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:209)
> at
>
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
> at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
> at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
> ..
> "
>
> The example should demonstrate creating and deploying an EJB bean to a
> server, accessing it using its JNDI name, and calling its method (persist,
> update, remove, list some entities).
> From what I understood is that annotated entities in the project should
> map/create mysql db tables if it is configured in persistence.xml file.
>
> When I deploy this project (as jar) to TomEE server, and start TomEE,
> openjpa does not create/map entities to mysql tables (no tables in mysql
> when i check it from terminal).
> I am not sure have I configured persistence.xml correctly, where
> persistence
> unit looks like this:
>
>transaction-type="RESOURCE_LOCAL">
>
> org.apache.openjpa.persistence.PersistenceProviderImpl
> 
>
>value="jdbc:mysql://localhost:3306/xyDB"/>
>value="com.mysql.jdbc.Driver"/>
>   
>   
>
>value="buildSchema(ForeignKeys=true)" />
>   
>   
> 
>   
>
> I believe this should be due some obvious setting i am missing, or not
> doing
> correctly.
> Appreciate any help or advice.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Persistence-xml-configuration-OpenJPA-not-mapping-entities-to-mysql-db-tp7585208.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: JDK 1.7 seems to be causing an issue with latest snapshot

2013-07-10 Thread Michael Dick
I had trouble with that too, but wasn't able to get to the bottom of it. If
you enable debug logging you might be able to spot the root cause.

It's a pain for unit testing, but the best approach might be to just list
the classes in persistence.xml with  tags.

-mike


On Tue, Jul 9, 2013 at 4:27 PM, garpinc  wrote:

> When this executes:
> EntityManagerFactory preWrappedEntityManagerFactory =
>
> Persistence.createEntityManagerFactory(JPAHelperFactory.getInstance().getPersistenceID(),
> jpaConf);
>
>
> I get:
> 359  jpastor  INFO   [main] openjpa.Enhance - You have enabled runtime
> enhancement, but have not specified the set of persistent classes.  OpenJPA
> must look for metadata for every loaded class, which might increase class
> load times significantly.
> 1600  jpastor  INFO   [main] openjpa.Runtime - OpenJPA dynamically loaded
> the class enhancer. Any classes that were not enhanced at build time will
> be
> enhanced when they are loaded by the JVM.
> 1600  jpastor  WARN   [main] openjpa.Runtime - OpenJPA dynamically loaded
> the class enhancer. Any classes that were not enhanced at build time will
> be
> enhanced when they are loaded by the JVM.
>
> even though jpaConf has following defined:
> openjpa.MetaDataFactory=jpa(Types=the classes...
>
> Am I missing something?
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/JDK-1-7-seems-to-be-causing-an-issue-with-latest-snapshot-tp7581417p7584373.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: JDK 1.7 seems to be causing an issue with latest snapshot

2013-07-08 Thread Michael Dick
Looks like the security classloader and the agent enhancer are defining the
same class (with the agent getting there first). Without any clue to which
classes are entities, the agent enhances everything it finds. Anecdotal
evidence suggests that it only takes one persistence unit without a list of
entities to cause the problem.

The logs will have something like this if that's the case:
65  test  INFO   [main] openjpa.Enhance - You have enabled runtime
enhancement, but have not specified the set of persistent classes.  OpenJPA
must look for metadata for every loaded class, which might increase class
load times significantly.

If you're getting this message the easiest workaround is to list your
entities in persistence.xml, or a mapping file. Failing that you can try a
system argument : -Dopenjpa.MetaDataFactory=Types=${list your classes here}
(but I didn't have much luck with this when I tried it).

Or, you could enhance as a build step. This
pagemight help.
Chances are you've already read it, but the next reader might
not have the link.

To automagically resolve this we'd have to make some (significant?) changes
to the agent, and we'd need a JIRA issue, if one hasn't already been opened.

If you can, try listing your entities, or running the enhancer prior to
running your app (and skip the javaagent). If neither works, let us know
and hopefully we'll be able to help.
-Mike



On Mon, Jul 8, 2013 at 2:23 PM, garpinc  wrote:

> Hi.. Is anyone working on this? I'm just getting back to some work that's
> dependent on this working and unfortunately my previously working system
> broke because the overall platform changed to 1.7 JDK.
>
> Thanks
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/JDK-1-7-seems-to-be-causing-an-issue-with-latest-snapshot-tp7581417p7584362.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: join-bad-col message key doesn't have corresponding message text

2013-02-01 Thread Michael Dick
Just a guess, but it looks like the entity has a bigInt mapping to a column
of char(4). I can't check the code / messages right now though, but maybe
this will give you a starting point.

-mike


On Fri, Feb 1, 2013 at 11:50 AM, Laird Nelson  wrote:

> I'm getting a metadata validation error and OpenJPA 2.2.1 is attempting to
> tell me something I'm sure is helpful, but the message key in question (
> join-bad-col) does not appear to have a related message.
>
> Here's the root error I'm getting:
>
> Caused by: 
> org.apache.openjpa.persistence.ArgumentException: localized message key: *
> join-bad-col*; substitutions:
> [com.foobar.RelationshipRecordBeanImpl.activeOn, bigint, Full Name:
> rel_table.REL
> Type: char
> Size: 4
> Default: null
> Not Null: true
> ]
> at
> org.apache.openjpa.jdbc.meta.MappingInfo.mergeColumn(MappingInfo.java:775)
>
>
> What is this error trying to tell me?  I know it's going to have to do with
> a @SecondaryTable annotation that is in play and probably its related
> @PrimaryKeyJoinColumn annotation, but to my eyes everything looks OK.
>
> Thanks,
> Laird
>
> --
> http://about.me/lairdnelson
>


Re: openjpa-kernel : using PostgreSQL's inet operators in JPQL

2012-11-15 Thread Michael Dick
You're right about not all of Kodo's features being added to OpenJPA.

Feel free to make a feature request, in JIRA. Unfortunately a lot of the
former Kodo developers are busy on other projects, and the rest of the
OpenJPA developers might not be familiar with Kodo's features.

What I'm getting at here is that you might have to do a lot of research to
get the feature into OpenJPA. We don't have the original implementers at
hand, or the original code base to donate.

-mike


On Thu, Nov 15, 2012 at 6:00 AM, RadeMartinovic  wrote:

> Michael,
>
> I did some research. I think that Query Filter Extensions were planed in
> Kodo but were not implemented. AFAIK big part of Kodo's codebase was at one
> point donated to OpenJPA. The only extension I've managed to find in the
> latest docs of OpenJPA is MethodQL.
>
> Other Query Language Extensions besides Filter Extensions were Aggregate
> Extensions, JDOQL Non-Distinct and JDOQL Subqueries.
>
> Do you think that I should make a feature request in OpenJPA's JIRA?
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-kernel-using-PostgreSQL-s-inet-operators-in-JPQL-tp7581619p7581764.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: openjpa-kernel : using PostgreSQL's inet operators in JPQL

2012-11-14 Thread Michael Dick
I think Marc published that prior to one of the older releases (OpenJPA
0.9.5, or 0.9.6). Take a look at the latest doc, and see if you can find
something similar there :
http://openjpa.apache.org/builds/latest/docs/docbook/manual.html

That feature may have been deprecated or renamed (I only took a quick look
though...

-mike




On Wed, Nov 14, 2012 at 7:44 AM, RadeMartinovic  wrote:

> Thank you for your answer.
>
> Do you think that Query Filter Extensions would be the way to go in my
> case?
> Are you aware of the development in that field?
>
> I've found this documentation
>
> http://people.apache.org/~mprudhom/openjpa/site/openjpa-project/manual/ref_guide_enterprise_queryext.html
> - but this is far from official... I am prepared to use OpenJPA from trunk
> or some branch that supports Query Filter Extensions.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-kernel-using-PostgreSQL-s-inet-operators-in-JPQL-tp7581619p7581738.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Any way to remove quote marks around generated sql for sybase schema?

2012-09-06 Thread Michael Dick
Hi Timothy,

This may seem like I'm nit-picking but bear with me. I think in Sybase the
naming convention is {database name}.{schema}.{object}, so in your example,
SHARE is the database name, and dbo is the schema. So you could set the
database name on you connection properties or datasource and just use this
in your entity:
@Table(name="PROVINCE", schema="dbo")

This is all fine and dandy so long as all your entities are in the same
Sybase database. If not, the most straight forward approach is to use a
separate EntityManagerFactory for each database.

That said, I think OpenJPA has detected a reserved character in your schema
name and is automatically delimiting it. There should be a way to escape
the . in your identifier (I'd try backslash but I'm not set up to test it
right now). Failing that, you could try disabling delimited identifiers on
the DBDictionary, and see if that helps.

Sorry I can't be of more help, I have limited Internet access at the
moment, I'll respond again when I get a chance to reproduce if you haven't
figured it out first.

-mike

On Mon, Sep 3, 2012 at 10:33 AM, Timothy Spring  wrote:

> Hi there,
>
>
>
> I have a datasource associated with a schema, and wish to select from a
>
> table on a different schema (to which I have access).
>
>
>
> Something like:
>
>
>
> SELECT name FROM SHARE.dbo.PROVINCE;
>
>
>
> (The "dbo" portion is a Sybase requirement, I've been told by the DBA?
>
> Whatever the case, the above works fine when run as is against sybase)
>
>
>
> Anyway, using annotations on my entity class as follows:
>
>
>
> @Entity
>
> @Table(name="PROVINCE", schema="SHARE.dbo")
>
>
>
> it generates sql with quote marks, eg:
>
>
>
> SELECT name FROM "SHARE.dbo".PROVINCE;
>
>
>
> Sybase hates this - is there any way I can configure openjpa to not
>
> quote the schema part?
>
>
>
> I had a look at the DBDictionary (and SybaseDictionary) docs, but
>
> couldn't see anything that seemed appropriate?
>
>
>
> Any help appreciated, please excuse any ignorance.
>
>
>
> I'm using openjpa-2.2.0
>
>
>
> Regards,
>
> Timothy Spring
>
>
>
>
>
>
>
>
>
>
>


Re: about variable DB schema name support

2012-01-21 Thread Michael Dick
Quick answer, you can use the openjpa.jdbc.Schema property at EMF creation
time. IIRC this won't work with EMF injection though.

A kludgy way to go would be to not define a schema in p.xml or in the
entities and let it pick up the default schema from your datasource. If you
can use a resource reference in persistence.xml then you can map the
resource reference to different datasources at deploy time.

You'd have to set a custom property on the datasource (or use different
logins) to get different schemas - but it should work.

Otherwise I think there'd have to be some additional hooks in the app
server at deploy time.

hth
-mike

On Thu, Jan 19, 2012 at 12:25 AM, yu wang  wrote:

> Hello gurus,
> When I were developing J2EE APP with OpenJPA, the db schema name is
> hard-coded into the annotation of Bean files and persistence.xml
> file,
> which incurs user cannot configure their DB schema name for the apps.
>
> Are there any chances we can let users determine their DB schema name
> when they deploy the J2ee app employing OpenJPA?
>
> Best Regards,
> Yu Wang
>


Re: Delete OptimisticLock exception, when entity appears 2x in cascade graph

2011-10-13 Thread Michael Dick
Just to add to Pinaki's reply.

OpenJPA can order the SQL updates appropriately, but only if the
openjpa.jdbc.UpdateManager is set to one of the constraint update managers
(constraint or batching-constraint). See this
sectionof
the manual for a little more information.

Note that using OpenJPA in RAD may have a different default value of this
configuration option. It might be best to explicitly set it to constraint to
ensure you're getting the expected value.

If you're sure you're using the constraint update manager, then you can tell
OpenJPA to read the database schema with the openjpa.SchemaFactory property.
Set it to 'native' in your persistence.xml file like this :
.

The SchemaFactory property controls how OpenJPA reads schema information.
The SynchronizeMappings property from Pinaki's email tells OpenJPA to build
the database objects based on your entities. They're related, but slightly
different.

Hope this helps
-mike


On Thu, Oct 13, 2011 at 8:16 AM, Pinaki Poddar  wrote:

> Hi,
> > I'm not at liberty to change this structure or the RI.
>   did you tell OpenJPA to read the database foreign key constraints?
> OpenJPA
> update can topologically sort a to-be-committed graph of objects to honor
> database constraints -- but the quality of sort depends on supplied
> information.
>  If you have not, please see openjpa.jdbc.SynchronizeMappings property.
>
> -
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Delete-OptimisticLock-exception-when-entity-appears-2x-in-cascade-graph-tp6882907p660.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: [DISCUSS] JDO usage end-of-life?

2011-10-10 Thread Michael Dick
There is at least some interest from a subset of our users. Matthew Adams
and issue: OPENJPA-1744
to add support for
JDO last July. I closed the issue, but Matthew responded
and the issue was reopened.

There hasn't been a lot of activity on the JIRA since then. There are some
users watching it, but no one has voted for it. If there's an outpouring of
support from the users list, and a committer (or aspiriing committer) is
interested in championing the effort, I'd be all for adding a JDO persona.
Absent a champion who is ready to dive into the code, I think that we should
clean up the references to jdo.

Even if OpenJPA removes the references to JDO, I'm sure a separate module
could be written that sits on top of our binaries. I suspect that's what BEA
/ Oracle did.

-mike



On Mon, Oct 10, 2011 at 8:18 AM, Kevin Sutter  wrote:

> Hi,
> Sorry to cross post to both forums, but I wanted to ensure that I hit
> everybody that might have an opinion on this JDO topic...
>
> Is the JDO personality of OpenJPA still being utilized?  Marc's recent post
> about possibly pulling in javax.jdo.* packages during the enhancement
> processing [1] reminded me that we still have old remnants of JDO (and
> Kodo)
> in the OpenJPA code base.  OpenJPA has never claimed support for JDO (nor
> Kodo).  Way back when, BEA provided a JDO implementation as part of their
> offering that sat on top of OpenJPA.  As far as I know, BEA (and Oracle)
> only support the 1.1.x service stream of OpenJPA.  So, if we did this in
> the
> 2.x stream, there should be no effects to that set of users.
>
> Would there be a concern with the current users of OpenJPA to clean up the
> code base and remove these JDO/Kodo references?  From a JPA/OpenJPA
> perspective, you should see no differences in functionality.
>
> Like I said, Marc's posting prompted me to revisit this topic.  I'm just
> exploring the option with no immediate plans of actually doing the work...
>
> Thanks,
> Kevin
>
> [1]
>
> http://openjpa.208410.n2.nabble.com/weird-JDO-Exception-when-using-OpenJPA-2-Enhancer-tc6870122.html
>


Re: Join fetch does not work if data cache is enabled

2011-09-23 Thread Michael Dick
OpenJPA has historically had problems with JOIN FETCH syntax, but this
sounds like a new bug.

Would you be adverse to trying OpenJPA's fetch plans instead? I mentioned it
in this post : http://markmail.org/message/wrqdyc22b2gaocux, and there's
some information in the manual at:
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_runtime_jpafetch.


In general fetch plans work more reliably with OpenJPA, and they might be a
workaround for you while we work on the bug.

hth
-mike

On Fri, Sep 23, 2011 at 8:07 AM, M. Walter  wrote:

> I wonder if I'm the first developer stumbling upon this one...
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Join-fetch-does-not-work-if-data-cache-is-enabled-tp6787245p6824153.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Unidirectional OneToMany without join table

2011-09-12 Thread Michael Dick
What version do you have in your persistence.xml file?

If the xml header indicates version 1.0 you'll get OpenJPA's old behavior
(and the error message you're seeing). If you have 2.0 in the xml header the
JoinColumn annotation should work.

-mike

On Sun, Sep 11, 2011 at 1:49 AM, koenr  wrote:

> According to
>
> http://en.wikibooks.org/wiki/Java_Persistence/OneToMany#Undirectional_OneToMany.2C_No_Inverse_ManyToOne.2C_No_Join_Table_.28JPA_2.0.29
> this article  JPA 2.0 supports Unidirectional OneToMany relationships,
> without having to use a join table.
>
> However, if I try to model this with OpenJPA 2.1.1, using the 
> tag, I receive an error "You have supplied columns for
> my.package.MyEntity.myList, but this mapping cannot have columns in this
> context."
>
> Does OpenJPA 2.1.1 support Unidirectional OneToMany relationships without a
> join table? If not, will this be part of OpenJPA 2.2?
>
> P.S. If I look at the "JSR-317 Persistence 2.0 Final Spec", it only seems
> to
> specify Unidirectional OneToMany relationships with join tables.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Unidirectional-OneToMany-without-join-table-tp6780201p6780201.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Enhancement necessary in GlassFish 3?

2011-09-12 Thread Michael Dick
There have been a few emails to this list about classpath issues when
enhancing on Glassfish. I don't think there's a definitive guide to getting
automatic enhancement working though, and the general consensus is to use
build time enhancement.

That said, if you can resolve the classpath problem you're currently
hitting, you'll probably be okay. There are two kinds of automatic
enhancement - a 'good' kind which involves bytecode insertion triggered by
the JRE or Application Server, and a 'bad' kind which dynamically creates a
subclass for your entities. It looks like you're hitting the 'good' kind but
some classloader issues are blocking you.

Short answer, I'd use build time enhancement unless there's a compelling
reason not to.

Hope this helps,
-mike

On Sat, Sep 10, 2011 at 8:29 AM, koenr  wrote:

> I deployed an .ear to GlassFish with the following structure:
>
> (Result from: jar tf MyProject.ear)
>
> META-INF/
> META-INF/MANIFEST.MF
> lib/
> lib/openjpa-all-2.1.1.jar
> lib/MyProject-pojo.jar
> MyProject-ejb.jar
> MyProject-ws.war
>
> Both MyProject-ejb.jar and MyProject-ws.war have a MANIFEST.MF file with a
> "Class-Path: lib/MyProject-pojo.jar" in them.
>
> However, when I deploy this .ear archive to GlassFish (3.1.1), I receive an
> error:
>
> [...]
> at
>
> org.apache.openjpa.enhance.PCClassFileTransformer.transform0(PCClassFileTransformer.java:144)
>   ... 77 more
> Caused by: java.lang.ClassNotFoundException: my.package.MyClass
> [...]
>
> Apart from the error message, which I'm still investigating, it looks as if
> GlassFish indeed automatically tries to enhance my entities.
>
> Can I safely ignore vague warnings on the web NOT to thrust this "auto
> enhance feature", or is there a particular reason I should still enhance
> the
> entities myself at build time (when deploying to GF3)?
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Enhancement-necessary-in-GlassFish-3-tp6778727p6778727.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Running PCEnhancer on a pile of classes that are not all entities

2011-09-07 Thread Michael Dick
This should be explained in our user manual. It'd be nice to reduce the
number of warning messages, and make them a little more friendly too.

I've opened a JIRA :
OPENJPA-2047<https://issues.apache.org/jira/browse/OPENJPA-2047>to
address the documentation, and look into a better way to log this
condition.

-mike

On Tue, Sep 6, 2011 at 11:45 AM, ljnelson  wrote:

> On Tue, Sep 6, 2011 at 12:24 PM, Michael Dick [via OpenJPA] <
> ml-node+6764535-652757152-155...@n2.nabble.com> wrote:
>
> > Typical applications will interact with entities (PersistenceCapable
> > classes) through the accessor and mutator methods anyway, so any
> > modifications should be a no-op. But the potential for modification is
> > there.
>
>
> Thanks.
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Running-PCEnhancer-on-a-pile-of-classes-that-are-not-all-entities-tp6759518p6764636.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Running PCEnhancer on a pile of classes that are not all entities

2011-09-06 Thread Michael Dick
The PCEnhancer has its roots in the Kodo (the JDO provider that OpenJPA is
based on). The answer to your question comes from the JDO spec :

Enhancement makes the following changes to persistence aware classes:
• modifies executable code that accesses fields of PersistenceCapable
classes
not known to be not managed, replacing getfield and putfield calls with
calls to the generated accessor and mutator methods.

Typical applications will interact with entities (PersistenceCapable
classes) through the accessor and mutator methods anyway, so any
modifications should be a no-op. But the potential for modification is
there.

Hope this helps,
-mike


On Sun, Sep 4, 2011 at 7:40 PM, Laird Nelson  wrote:

> I wanted to verify that this ominous PCEnhancer warning:
>
> 3294  weaving  WARN   [main] openjpa.Enhance - Type "class
> > com.foobar.FoobarPropertyEditor" loaded by
> > org.apache.openjpa.lib.util.TemporaryClassLoader@5fd1358f has no
> metadata;
> > enhancing as persistence aware. If you intended for "class
> > com.FoobarPropertyEditor" to be persistence-capable, then this means that
> > OpenJPA could not find any metadata for "class
> > com.foobar.FoobarPropertyEditor". This can happen if the directory
> > containing your metadata is not in your CLASSPATH, or if your metadata
> files
> > are not named properly. See the documentation on metadata placement for
> more
> > information.
> >
>
> ...simply means that the OpenJPA PCEnhancer effectively took no action on
> the class in question.
>
> I am running the PCEnhancer through Ant as invoked by the
> maven-antrun-plugin; I have opted to run it over a directory tree (via
> Ant's
>  element) rather than specifying the  files in the
> persistence.xml.  For various reasons, this means that among the many
> .classfiles in the directory tree are classes that are not entities.
> I want to
> make sure that they are not being modified in any way.  I looked at the
> .class file in emacs and didn't see anything obvious.
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>


Re: GenerationType.TABLE question: column name suffixed with 0?

2011-09-01 Thread Michael Dick
The issue is OPENJPA-2045<https://issues.apache.org/jira/browse/OPENJPA-2045>,
if the workaround doesn't work for you let us know and we'll take a look at
that aspect too.

-mike

On Thu, Sep 1, 2011 at 8:53 AM, ljnelson  wrote:

> On Thu, Sep 1, 2011 at 9:52 AM, Michael Dick [via OpenJPA] <
> ml-node+6750086-1384401919-155...@n2.nabble.com> wrote:
>
> > You're right, this is a bug. "NAME" is in the default set of reserved
> words
> >
> > that can't be used as column names. It appears to be valid for H2 though
> > and
> > we should handle it appropriately. Can you file a JIRA issue, or would
> you
> > like me to do that on your behalf?
> >
>
> Sounds like you know roughly where it is; if you wouldn't mind filing it
> yourself it would probably be a better bug report for it.  :-)
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/GenerationType-TABLE-question-column-name-suffixed-with-0-tp6729676p6750091.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: GenerationType.TABLE question: column name suffixed with 0?

2011-09-01 Thread Michael Dick
You're right, this is a bug. "NAME" is in the default set of reserved words
that can't be used as column names. It appears to be valid for H2 though and
we should handle it appropriately. Can you file a JIRA issue, or would you
like me to do that on your behalf?

You can escape the name column as a workaround  :
@javax.persistence.TableGenerator(
name = "fred",
table = "jpa_sequence",
pkColumnName = "\"name\"",
valueColumnName = "last_value",
pkColumnValue = "fred",
allocationSize = 500)

-mike

On Fri, Aug 26, 2011 at 1:36 PM, Laird Nelson  wrote:

> On Fri, Aug 26, 2011 at 1:49 PM, Laird Nelson  wrote:
>
> > OpenJPA tries to read a column called "NAME0", which is not defined
> > anywhere.
> >
>
> Changing the name of the sequence table column from "NAME" to
> "SEQUENCE_NAME" fixed the problem.  Bug in OpenJPA, I think.  Maybe in the
> H2 dictionary?
>
> Best,
> Laird
> --
> http://about.me/lairdnelson
>


Re: IntId cannot be cast to ContainerShipment with FetchType.EAGER

2011-09-01 Thread Michael Dick
Hi Marc,

Could you post the query you're using, and any properties from
persistence.xml? I took a quick shot at reproducing the problem, but haven't
had any luck, maybe the query / persistence properties will help me narrow
in on the problem.

-mike

On Mon, Aug 29, 2011 at 6:07 PM, Marc Logemann  wrote:

> hmm. it seems to be a data issue but a strange one. If the child entity
> (OrderPosition) has no reference to an entity in ContainerShipment (parent),
> i will get this stack trace. Normally i would think that attribute
> List orderPositions would be null in ContainerShipment and
> everything is fine but somehow i need at least one "n" relation. Never
> experienced this
>
> Here is my back reference in OrderPosition.
>
>@ManyToOne
>@JoinColumn(name = "con_ship_id", referencedColumnName = "id")
>ContainerShipment containerShipment;
>
> still confused.
>
> ---
> regards
> Marc Logemann
> http://www.logemann.org
> http://www.logentis.de
>
>
>
>
> Am 29.08.2011 um 23:57 schrieb Marc Logemann:
>
> > Hi,
> >
> > aother openjpa thing. Most likely again not a bug but i will try ;-)
> >
> > I have a normal 1:n relation in my ContainerShipment class which works
> pretty well.
> >
> >@OneToMany(mappedBy = "containerShipment", cascade = CascadeType.ALL)
> >List orderPositions;
> >
> > but as soon as i annotate with FetchType.EAGER...
> >
> >@OneToMany(mappedBy = "containerShipment", cascade = CascadeType.ALL,
> fetch = FetchType.EAGER)
> >List orderPositions;
> >
> > i get this stack trace and i really dont have a clue. I checked
> gazillions of things w/o success. I also made sure that every record as a
> perfect relation so that i can be sure thats not a data content issue. Any
> ideas?
> >
> >
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
> > root cause java.lang.ClassCastException:
> org.apache.openjpa.util.IntId cannot be cast to
> de.logentis.bwh.model.ContainerShipment
> >
> de.logentis.bwh.model.OrderPosition.pcReplaceField(OrderPosition.java)
> >
> org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3162)
> >
> org.apache.openjpa.kernel.StateManagerImpl.storeObjectField(StateManagerImpl.java:2596)
> >
> org.apache.openjpa.kernel.StateManagerImpl.storeObject(StateManagerImpl.java:2586)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setMappedBy(JDBCStoreManager.java:505)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:431)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
> >
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
> >
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> >
> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1027)
> >   org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:985)
> >   org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:907)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1041)
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
> >
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
> >
> org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:90)
> >
> org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStrategy.loadElement(RelationCollectionInverseKeyFieldStrategy.java:76)
> >
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.processEagerParallelResult(StoreCollectionFieldStrategy.java:312)
> >
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.loadEagerParallel(StoreCollectionFieldStrategy.java:246)
> >
> org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerParallel(FieldMapping.java:916)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1114)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1067)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:438)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
> >
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
> >
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> >
> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1027)
> >   org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:985)
> >   org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:907)
> >
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1041)
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
> >
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.jav

Re: openJPA dependcies with latest openJPA-2.1.x and javax.persistance.PersistanceProvider / javaee-apo

2011-08-18 Thread Michael Dick
Hi Sebastian,

The binary downloads of OpenJPA includes the Java EE jars we use with
OpenJPA (look in the lib directory). The spec implementations we use come
from Geronimo, but any Java EE 6.0 compliant version of the API should work
for you.

You can also find these jars in the maven central repository at :
http://search.maven.org/#search|ga|1|a%3A%22geronimo-jpa_2.0_spec%22

I did check the geronimo-jpa jar and it does contain a few geronimo specific
classes, I believe these are used with OSGi and should not cause any
problems for you.

I'm sorry I don't have sufficient experience with Tomcat to give advice on
where the jars should go. Hopefully someone else on the list can help with
that.

-mike

On Thu, Aug 18, 2011 at 10:28 AM, Craig L Russell
wrote:

> Cross posting from users...
>
> Can anyone help?
>
> Craig
>
> Begin forwarded message:
>
>  From: "seba.wag...@gmail.com" 
>> Date: August 18, 2011 12:24:04 AM PDT
>> To: users@openjpa.apache.org
>> Subject: openJPA dependcies with latest openJPA-2.1.x and
>> javax.persistance.**PersistanceProvider / javaee-apo
>> Reply-To: users@openjpa.apache.org
>>
>>
>> Hi,
>>
>> we are migrating a larger Open Source project (OpenMeetings) from
>> Hibernate
>> to openJPA for Apache incubation and face some issues with openJPA's
>> dependencies to javax.persistance.**PersistanceProvider:
>>
>>
>> We already have the javaee-api-5.1.1.jar (
>> http://openmeetings.**googlecode.com/svn/trunk/**
>> singlewebapp/server/red5/lib/**javaee-api-5.1.1.jar
>> )
>> in the servers lib that has an incompatible version of the interface
>> javax.persistance.**PersistanceProvide.
>> The application server is a modified Tomcat server integrated with Spring.
>>
>> Now the questions is:
>> When we use the openjpa-2.1.x-all.jar and remove the javax.persistance.*
>> classes from javaee-api-5.1.1.jar we HAVE to move openjpa-2.1.x-all.jar to
>> the servers/lib (instead of webapps/openmeetings/WEB-INF/**lib) because
>> the
>> application server itself needs the javax.perstistance.* classes available
>> too.
>>
>> Separating the javax.perstistance.* from the openjpa-2.1.x-all.jar and
>> just
>> moving that to the server-lib doesn't work too as those
>> javax.perstistance.*
>> from the openjpa-2.1.x-all.jar seem to have some depencies to
>> *apache.geronimo.xyz*.
>>
>> So my questions are:
>> Where can we get a javax.persistance.* library that is compatible with
>> openJPA-2.1.x ? The one from the maven directory:
>> http://download.java.net/**maven/2/javax/javaee-api/6.0/does
>>  NOT work. It
>> throws some Exception about invalid class. Seems like a compile error in
>> their build server.
>>
>> Where is the best place to put the openJPA-2.1.x JAR(s) ? Servers-lib or
>> WEB-INF/lib ? We want to be able to deploy multiple times the
>> openmeetings-webapp into the same applications server. From my point of
>> view
>> you have to put them into WEB-INF/lib then?
>>
>>
>> Thank you very much,
>> Sebastian
>>
>>
>> --
>> Sebastian Wagner
>> http://www.webbase-design.de
>> http://openmeetings.**googlecode.com 
>> http://www.wagner-sebastian.**com 
>> seba.wag...@gmail.com
>>
>
> Craig L Russell
> Architect, Oracle
> http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@oracle.**com 
> P.S. A good JDO? O, Gasp!
>
>


Re: Problems when using "openjpa.MetaDataFactory" Property

2011-08-15 Thread Michael Dick
Hi Marcel,

I'm sorry Slice wasn't the answer for you. Go ahead and open a JIRA.

-mike

On Mon, Aug 15, 2011 at 2:36 AM, Marcel Urbanek wrote:

> Hi,
>
> I now found following in the documentation:
>
> > Slice will ensure that all other related instances that get persisted by
> cascade are assigned to the same database slice as that of the root
> instance.
>
> So sadly this won't work for us, as associated entites can be in different
> schemas.
>
> Should I file a JIRA for the MetaDataFactory Bug?
>
> Best regards, Marcel
>
>
> From:   Marcel Urbanek 
> To: users@openjpa.apache.org
> Date:   12.08.2011 16:59
> Subject:Re: Problems when using "openjpa.MetaDataFactory" Property
>
>
>
> Hi,
>
> I will give it a try (on monday) but looking at the documentation I'm not
> sure if it is possible to do joins over two entites from two different
> slices. I fear that won't work (as they could be even from different
> datasources).
>
> Best regards Marcel
>
>
>
> From:   Michael Dick 
> To: users@openjpa.apache.org
> Date:   12.08.2011 16:03
> Subject:Re: Problems when using "openjpa.MetaDataFactory" Property
>
>
>
> It's a thorny problem.
>
> Have you looked at
> openjpa-slice<
>
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_slice
>
> >?
> Having a separate slice for each schema sounds like it would work for you.
>
> I
> haven't tried anything like what you want to do, but you should be able to
> set a different schema on each slice. Failing that you might be able to
> use
> different users and pick up a different default schema that way.
>
> -mike
>
> On Fri, Aug 12, 2011 at 4:54 AM, Marcel Urbanek
> wrote:
>
> > Hi,
> >
> > thanks for your answer.
> >
> > We need to specify differing qualifier/schemas for the entities.
> >
> > So lets say Entity A is in Qualifier 'test1' and Entity B is in
> Qualifier
> > 'test2'.
> > Furthermore, depending on the platform the program is run, the Qualifier
> > may change. On Production Platform the Qualifier might be 'prod1' and
> > 'prod2' instead of 'test1' and 'test2'. And last but not least it should
> > also be possible to do joins between the two entities, while being in
> > differnet schemas/qualifiers.
> >
> > Following options do not work for us:
> >
> > - Specify the schema at the annotation (because the schema name changes
> > from platform to platform)
> > - Implementing an own OpenJPAEntityManagerFactory that set the schema
> for
> > the according persistence unit (because joins between the two
> persistence
> > units would not be possible)
> >
> > The idea was to implement a MetaDataFactory that returns a custom
> > MetaDataParser that itself handles the schemas in the
> > handleUnknownClassAnnotation() Method (via a custom @Qualifier
> annotation)
> > and manipulates the MetaData accordingly.
> >
> > Best regards Marcel
> >
> >
> >
> > From:   Michael Dick 
> > To: users@openjpa.apache.org
> > Date:   11.08.2011 21:57
> > Subject:Re: Problems when using "openjpa.MetaDataFactory"
> Property
> >
> >
> >
> > Hi again,
> >
> > I did a little digging and I have a couple of ideas on how to fix the
> > problem. Can you tell me what you want to do with your extension to the
> > MappingFactory? There might be another way to get what you need to do
> > done.
> > Or at least a different workaround that you can use while we work on a
> > fix.
> >
> > -mike
> >
> > On Thu, Aug 11, 2011 at 2:19 PM, Michael Dick
> > wrote:
> >
> > > Hi Marcel,
> > >
> > > Thanks for sending the embeddable PK, I was missing that part.
> > >
> > > I see everything work if I set the MappingFactory plugin to the
> default
> > > value (org.apache.openjpa...) or leave the property blank. When I use
> a
> > > custom mapping factory I get the error where the column names aren't
> > picked
> > > up (bad SQL is generated).
> > >
> > > For some reason when you've specified your own MappingFactory OpenJPA
> > > forces the factory into strict mode and the column names are not
> > processed.
> > > It's fairly easy to change the code to not do that, but I'm not sure
> > what
> > > else I'd break.
> > >
> > > I haven

Re: Possibility to return detached objects from a query?

2011-08-12 Thread Michael Dick
Some of the detach behavior depends on the version in your persistence.xml
file. It's kind of a shot in the dark, but are you validating against
version 2.0, or 1.0?

-mike

On Fri, Aug 12, 2011 at 9:56 AM, Michael Pflueger
wrote:

> Hi Rick,
>
> Yes, I'm using 2.2 trunk, ~1 week old.
>
> I did try LRS in the past, but as I encountered a bug there I switched away
> from it.
> This bug seems to be fixed in trunk, but I could only use LRS for Importing
> data anyway, as our main DB is MySQL, which lacks proper LRS support with
> concurrent queries.
>
> Thus, I wrote a simple query chunker which loads a chunk  of results from
> the db, provides an iterator, and upon reaching the end automatically loads
> the next chunk, etc.
>
> So, I could try LRS for the purpose of debugging etc, but it should work
> without them aswell.
>
> And Yes! After a quick check, with CopyOnDetach=false, OpenJPA behaves as
> expected and does not use more than about 30MB of Heap space and most
> importantly stays in that range. (as long as I detach my entities :)
>
> Thanks!
>
> I'd still be interested whether it's a bug in the copyOnDetach=true
> codepath or if it is working as designed that the manager keeps managed
> copies on detachment?
>
> -Ursprüngliche Nachricht-
> Von: Rick Curtis [mailto:curti...@gmail.com]
> Gesendet: Donnerstag, 11. August 2011 16:11
> An: users@openjpa.apache.org
> Betreff: Re: Possibility to return detached objects from a query?
>
> Michael -
>
> > While I still wonder about why detaching my entities doesn't reduce my
> heap memory usage
> You didn't mention what level of code you are running on, but if it is >
> 2.0, it might be a bug. Try setting the following property:  name="openjpa.Compatibility" value="CopyOnDetach=false"/>
>
> > also wonder whether there is a possibility for a query to return detached
> objects in the first place?
> I'm not aware of one. That doesn't mean the capability doesn't exist, I'm
> just not aware of it :)
>
> > Calling detach() for every object looks to be rather expensive
> Correct, in some of our performance testing we have found that detach is
> quite expensive. I put in a property LiteAutoDetach which is in place to
> quickly detach the entire persistence context, but unfortunately this
> optimization isn't available for detaching single instances.
>
> I know I missed an email you sent to this list a number of days ago where
> you were asking a very similar question. I don't want to derail this
> thread,
> but have you looked at large result sets[1]? The might simplify some of
> your
> loading code.
>
>
> [1]
>
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_lrs
>
> Thanks,
> Rick
>
> On Thu, Aug 11, 2011 at 2:06 AM, Michael Pflueger
> wrote:
>
> > Hi,
> >
> > While I still wonder about why detaching my entities doesn't reduce my
> heap
> > memory usage,
> > I also wonder whether there is a possibility for a query to return
> detached
> > objects in the first place?
> > This might be quite efficient for scenarios where you need to read lots
> of
> > data but not update it or need any other features of a managed entity.
> > Calling detach() for every object looks to be rather expensive, and above
> > method would not only avoid that but could possibly avoid some attachment
> > overhead aswell.
> > ___
> >
> > SMA Solar Technology AG
> > Aufsichtsrat: Guenther Cramer (Vorsitzender)
> > Vorstand: Juergen Dolle, Roland Grebe, Uwe Hertel, Pierre-Pascal Urbon,
> > Marko Werner
> > Handelsregister: Amtsgericht Kassel HRB 3972
> > Sitz der Gesellschaft: 34266 Niestetal
> > USt-ID-Nr. DE 113 08 59 54
> > WEEE-Reg.-Nr. DE 95881150
> > ___
> >
> >
>
>
> --
> *Rick Curtis*
>


Re: Memory Management, reading huge tables fills heap space

2011-08-12 Thread Michael Dick
I don't think this behavior is normal, but I haven't had a chance to look
into it. If you have a testcase handy that usually makes things quicker for
us - but we should be able to produce one fairly quickly.

In another thread Rick suggested using OpenJPA's
LRSsupport,
have you been able to give that a try?

-mike

On Thu, Aug 4, 2011 at 9:33 AM, Michael Pflueger wrote:

> Hi,
>
> I'm reading a huge table with openJPA in chunks, like this:
>
> List list = query.setMaxResults(batchSize).setFirstResult(position *
> batchSize).getResultList();
>
>
> And iterate over it like this:
>
>for (Entity e : list) {
>//entityManager.detach(e);
>}
>
> Now my Java Heap Space fills slowly up to around close to 100%, then stays
> around that value, sometimes it starts fluctuating...
>
> Now I uncommented entityManager.detach(e), but it behaves more or less the
> same, it fills my whole heap space.
> In small tests I have not gotten an OutOfMemoryException yet, but the
> bigger production app I need this for already got some after some runtime...
>
> I don't really understand this behavior, is there anything I can do about
> it?
> I already tried removing the detached state field from the Entity but that
> does not seem to help either.
>
> What does help is repeatedly calling entityManager.clear() to clear the
> whole context, but this solution might not always be desireable.
>
> So, besides possible solutions I also wonder if this behavior is "normal"
> or whether I should try to create a small testCase for this aswell.
>
>
> Regards,
> Michael
> ___
>
> SMA Solar Technology AG
> Aufsichtsrat: Guenther Cramer (Vorsitzender)
> Vorstand: Juergen Dolle, Roland Grebe, Uwe Hertel, Pierre-Pascal Urbon,
> Marko Werner
> Handelsregister: Amtsgericht Kassel HRB 3972
> Sitz der Gesellschaft: 34266 Niestetal
> USt-ID-Nr. DE 113 08 59 54
> WEEE-Reg.-Nr. DE 95881150
> ___
>
>


Re: Problems when using "openjpa.MetaDataFactory" Property

2011-08-12 Thread Michael Dick
It's a thorny problem.

Have you looked at
openjpa-slice<http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_slice>?
Having a separate slice for each schema sounds like it would work for you. I
haven't tried anything like what you want to do, but you should be able to
set a different schema on each slice. Failing that you might be able to use
different users and pick up a different default schema that way.

-mike

On Fri, Aug 12, 2011 at 4:54 AM, Marcel Urbanek wrote:

> Hi,
>
> thanks for your answer.
>
> We need to specify differing qualifier/schemas for the entities.
>
> So lets say Entity A is in Qualifier 'test1' and Entity B is in Qualifier
> 'test2'.
> Furthermore, depending on the platform the program is run, the Qualifier
> may change. On Production Platform the Qualifier might be 'prod1' and
> 'prod2' instead of 'test1' and 'test2'. And last but not least it should
> also be possible to do joins between the two entities, while being in
> differnet schemas/qualifiers.
>
> Following options do not work for us:
>
> - Specify the schema at the annotation (because the schema name changes
> from platform to platform)
> - Implementing an own OpenJPAEntityManagerFactory that set the schema for
> the according persistence unit (because joins between the two persistence
> units would not be possible)
>
> The idea was to implement a MetaDataFactory that returns a custom
> MetaDataParser that itself handles the schemas in the
> handleUnknownClassAnnotation() Method (via a custom @Qualifier annotation)
> and manipulates the MetaData accordingly.
>
> Best regards Marcel
>
>
>
> From:   Michael Dick 
> To: users@openjpa.apache.org
> Date:   11.08.2011 21:57
> Subject:Re: Problems when using "openjpa.MetaDataFactory" Property
>
>
>
> Hi again,
>
> I did a little digging and I have a couple of ideas on how to fix the
> problem. Can you tell me what you want to do with your extension to the
> MappingFactory? There might be another way to get what you need to do
> done.
> Or at least a different workaround that you can use while we work on a
> fix.
>
> -mike
>
> On Thu, Aug 11, 2011 at 2:19 PM, Michael Dick
> wrote:
>
> > Hi Marcel,
> >
> > Thanks for sending the embeddable PK, I was missing that part.
> >
> > I see everything work if I set the MappingFactory plugin to the default
> > value (org.apache.openjpa...) or leave the property blank. When I use a
> > custom mapping factory I get the error where the column names aren't
> picked
> > up (bad SQL is generated).
> >
> > For some reason when you've specified your own MappingFactory OpenJPA
> > forces the factory into strict mode and the column names are not
> processed.
> > It's fairly easy to change the code to not do that, but I'm not sure
> what
> > else I'd break.
> >
> > I haven't found a workaround for you yet, but at least I can reproduce
> the
> > problem.
> >
> > -mike
> >
> >
> > On Thu, Aug 11, 2011 at 10:18 AM, Marcel Urbanek
> wrote:
> >
> >> Hi,
> >>
> >> please note that my example/junit test works fine as long as I don't
> >> change the Mapping Factory properties. Only when changing the
> >> MappingFactory it goes wrong.
> >>
> >> My Group Entity looks like this:
> >>
> >>
> >>@Embeddable
> >>public class GroupPK {
> >>/*Group Number*/
> >>@Column(name = "NU_GRP",
> >>length=2)
> >>private Short  groupNumber;
> >>
> >>/*Group name*/
> >>@Column(name = "NA_GRP",
> >>length=20)
> >>private String  groupName;
> >>
> >>/*Valid from*/
> >>@Temporal(TemporalType.DATE)
> >>@Column(name = "DA_VAL_FRM",
> >>length=4)
> >>private Date  validFromDate;
> >>...
> >>
> >>
> >>@Entity
> >>@Table(name="MPTZZY")
> >>public class Group extends UpdateEntity{
> >>
> >>/*Remark text*/
> >>@Column(name = "TE_RMK",
> >>length=20)
> >>private String  remark

Re: Problems when using "openjpa.MetaDataFactory" Property

2011-08-11 Thread Michael Dick
Hi again,

I did a little digging and I have a couple of ideas on how to fix the
problem. Can you tell me what you want to do with your extension to the
MappingFactory? There might be another way to get what you need to do done.
Or at least a different workaround that you can use while we work on a fix.

-mike

On Thu, Aug 11, 2011 at 2:19 PM, Michael Dick wrote:

> Hi Marcel,
>
> Thanks for sending the embeddable PK, I was missing that part.
>
> I see everything work if I set the MappingFactory plugin to the default
> value (org.apache.openjpa...) or leave the property blank. When I use a
> custom mapping factory I get the error where the column names aren't picked
> up (bad SQL is generated).
>
> For some reason when you've specified your own MappingFactory OpenJPA
> forces the factory into strict mode and the column names are not processed.
> It's fairly easy to change the code to not do that, but I'm not sure what
> else I'd break.
>
> I haven't found a workaround for you yet, but at least I can reproduce the
> problem.
>
> -mike
>
>
> On Thu, Aug 11, 2011 at 10:18 AM, Marcel Urbanek wrote:
>
>> Hi,
>>
>> please note that my example/junit test works fine as long as I don't
>> change the Mapping Factory properties. Only when changing the
>> MappingFactory it goes wrong.
>>
>> My Group Entity looks like this:
>>
>>
>>@Embeddable
>>public class GroupPK {
>>/*Group Number*/
>>@Column(name = "NU_GRP",
>>length=2)
>>private Short  groupNumber;
>>
>>/*Group name*/
>>@Column(name = "NA_GRP",
>>length=20)
>>private String  groupName;
>>
>>/*Valid from*/
>>@Temporal(TemporalType.DATE)
>>@Column(name = "DA_VAL_FRM",
>>length=4)
>>private Date  validFromDate;
>>...
>>
>>
>>@Entity
>>@Table(name="MPTZZY")
>>public class Group extends UpdateEntity{
>>
>>/*Remark text*/
>>@Column(name = "TE_RMK",
>>length=20)
>>private String  remarkText;
>>
>> @OneToMany(mappedBy="group",fetch=FetchType.EAGER
>> ,cascade=CascadeType.ALL)
>>Collection persons=new ArrayList();
>>
>>@EmbeddedId
>>private GroupPK id = new GroupPK();
>>...
>>
>>
>>
>> Best regards Marcel
>>
>>
>>
>>
>>
>> From:   Michael Dick 
>> To: users@openjpa.apache.org
>> Date:   11.08.2011 16:36
>> Subject:Re: Problems when using "openjpa.MetaDataFactory" Property
>>
>>
>>
>> Going back to your original email, the documentation is misleading. While
>> you could use PersistenceMetaDataFactory you'd probably prefer to use
>> PersistenceMappingFactory. Basically, you did the right thing by extending
>> the PersistenceMappingFactory..
>>
>> The product derivations are confusing, because they set the same alias.
>> But
>> they should always be applied in a consistent order. There's some tricky
>> ordering in the code, but basically the PersistenceProductDerivation
>> should
>> always be called before JDBCPersistenceProductDerivation.
>>
>> If all you want to do is override the MetaDataFactory you do not need to
>> write your own product derivation. ProductDerivations are needed if you
>> want
>> to support a different type of data store (maybe a non-relational
>> database),
>> or a different spec (JDO). I don't see a reason why you'd need to go that
>> far.
>>
>> All that said, I think we're going to need to know more about your model
>> to
>> figure out what is going wrong here. In particular what annotations are on
>> the NA_GRP column.
>>
>> Once we get this to work with the OpenJPA defaults, we can look at what
>> goes
>> wrong with your MappingFactory.
>>
>> HTH
>> -mike
>>
>> On Thu, Aug 11, 2011 at 2:32 AM, Marcel Urbanek
>> wrote:
>>
>> > Hi Rick,
>> >
>> > when I use
>> >
>> >> > />
>> >
>> > The same error ("no registered metadata") occur

Re: Problems when using "openjpa.MetaDataFactory" Property

2011-08-11 Thread Michael Dick
Hi Marcel,

Thanks for sending the embeddable PK, I was missing that part.

I see everything work if I set the MappingFactory plugin to the default
value (org.apache.openjpa...) or leave the property blank. When I use a
custom mapping factory I get the error where the column names aren't picked
up (bad SQL is generated).

For some reason when you've specified your own MappingFactory OpenJPA forces
the factory into strict mode and the column names are not processed. It's
fairly easy to change the code to not do that, but I'm not sure what else
I'd break.

I haven't found a workaround for you yet, but at least I can reproduce the
problem.

-mike

On Thu, Aug 11, 2011 at 10:18 AM, Marcel Urbanek wrote:

> Hi,
>
> please note that my example/junit test works fine as long as I don't
> change the Mapping Factory properties. Only when changing the
> MappingFactory it goes wrong.
>
> My Group Entity looks like this:
>
>
>@Embeddable
>public class GroupPK {
>/*Group Number*/
>@Column(name = "NU_GRP",
>length=2)
>private Short  groupNumber;
>
>/*Group name*/
>@Column(name = "NA_GRP",
>length=20)
>private String  groupName;
>
>/*Valid from*/
>@Temporal(TemporalType.DATE)
>@Column(name = "DA_VAL_FRM",
>length=4)
>private Date  validFromDate;
>...
>
>
>@Entity
>@Table(name="MPTZZY")
>public class Group extends UpdateEntity{
>
>/*Remark text*/
>@Column(name = "TE_RMK",
>length=20)
>private String  remarkText;
>
> @OneToMany(mappedBy="group",fetch=FetchType.EAGER
> ,cascade=CascadeType.ALL)
>Collection persons=new ArrayList();
>
>@EmbeddedId
>private GroupPK id = new GroupPK();
>...
>
>
>
> Best regards Marcel
>
>
>
>
>
> From:   Michael Dick 
> To: users@openjpa.apache.org
> Date:   11.08.2011 16:36
> Subject:Re: Problems when using "openjpa.MetaDataFactory" Property
>
>
>
> Going back to your original email, the documentation is misleading. While
> you could use PersistenceMetaDataFactory you'd probably prefer to use
> PersistenceMappingFactory. Basically, you did the right thing by extending
> the PersistenceMappingFactory..
>
> The product derivations are confusing, because they set the same alias.
> But
> they should always be applied in a consistent order. There's some tricky
> ordering in the code, but basically the PersistenceProductDerivation
> should
> always be called before JDBCPersistenceProductDerivation.
>
> If all you want to do is override the MetaDataFactory you do not need to
> write your own product derivation. ProductDerivations are needed if you
> want
> to support a different type of data store (maybe a non-relational
> database),
> or a different spec (JDO). I don't see a reason why you'd need to go that
> far.
>
> All that said, I think we're going to need to know more about your model
> to
> figure out what is going wrong here. In particular what annotations are on
> the NA_GRP column.
>
> Once we get this to work with the OpenJPA defaults, we can look at what
> goes
> wrong with your MappingFactory.
>
> HTH
> -mike
>
> On Thu, Aug 11, 2011 at 2:32 AM, Marcel Urbanek
> wrote:
>
> > Hi Rick,
> >
> > when I use
> >
> > > />
> >
> > The same error ("no registered metadata") occurs.
> >
> > After some investigation (looking at JDBCPersistenceProductDerivation) I
> > found out that following configuration:
> >
> > > "org.apache.openjpa.persistence.PersistenceMetaDataFactory"/>
> >  > "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory"/>
> > > "org.apache.openjpa.persistence.jdbc.PersistenceMappingDefaults"/>
> >
> > Leads to following Exception:
> >
> >org.apache.openjpa.persistence.ArgumentException: You cannot join
> > on column "MPTZZY.NA_GRP".  It is not managed by a mapping that supports
> > joins.
> >
> > which looks a little better to me?
> >
> > Actually I think the main problem is, that PersistenceProductDerivation
> > and JDBCPersistenceProd

Re: Problems when using "openjpa.MetaDataFactory" Property

2011-08-11 Thread Michael Dick
Going back to your original email, the documentation is misleading. While
you could use PersistenceMetaDataFactory you'd probably prefer to use
PersistenceMappingFactory. Basically, you did the right thing by extending
the PersistenceMappingFactory..

The product derivations are confusing, because they set the same alias. But
they should always be applied in a consistent order. There's some tricky
ordering in the code, but basically the PersistenceProductDerivation should
always be called before JDBCPersistenceProductDerivation.

If all you want to do is override the MetaDataFactory you do not need to
write your own product derivation. ProductDerivations are needed if you want
to support a different type of data store (maybe a non-relational database),
or a different spec (JDO). I don't see a reason why you'd need to go that
far.

All that said, I think we're going to need to know more about your model to
figure out what is going wrong here. In particular what annotations are on
the NA_GRP column.

Once we get this to work with the OpenJPA defaults, we can look at what goes
wrong with your MappingFactory.

HTH
-mike

On Thu, Aug 11, 2011 at 2:32 AM, Marcel Urbanek wrote:

> Hi Rick,
>
> when I use
>
> />
>
> The same error ("no registered metadata") occurs.
>
> After some investigation (looking at JDBCPersistenceProductDerivation) I
> found out that following configuration:
>
> "org.apache.openjpa.persistence.PersistenceMetaDataFactory"/>
>  "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory"/>
> "org.apache.openjpa.persistence.jdbc.PersistenceMappingDefaults"/>
>
> Leads to following Exception:
>
>org.apache.openjpa.persistence.ArgumentException: You cannot join
> on column "MPTZZY.NA_GRP".  It is not managed by a mapping that supports
> joins.
>
> which looks a little better to me?
>
> Actually I think the main problem is, that PersistenceProductDerivation
> and JDBCPersistenceProductDerivation both are setting the "JPA" Alias.
>
> But one sets MetaDataFactory for Alias JPA whith
> PersistenceMetaDataFactory and one sets MetaDataFactory for Alias JPA with
> PersistenceMappingFactory. During execution both,
> PersistenceProductDerivation and JDBCPersistenceProductDerivation are
> invoked which results in MetaDataFactory being set to the one or the other
> value, depending on which Derivation was called lately. This is nothing
> one could easily configure in the persistence.xml.
>
> Instead I would have to implement an own Derivation? I am a little
> confused.
>
> Best regards Marcel
>
>
>
>
> From:   Rick Curtis 
> To: users@openjpa.apache.org
> Date:   10.08.2011 18:31
> Subject:Re: Problems when using "openjpa.MetaDataFactory" Property
>
>
>
> Try specifying your types also -->  name="openjpa.MetaDataFactory"
>
> value="org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory(types=com.retail_sc.test.entity.Group;com.retail_sc.test.entity.Group2;...etc/>
>
> This happens at runtime, but I can't find where it happens atm.
>
> On Wed, Aug 10, 2011 at 11:12 AM, Marcel Urbanek
> wrote:
>
> > Then following Stacktrace is displayed:
> >
> > Caused by: 
> > org.apache.openjpa.persistence.ArgumentException: Errors encountered
> while
> > resolving metadata.  See nested exceptions for details.
> >at
> >
> >
>
> org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:563)
> >at
> >
> >
>
> org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
> > ...
> > Caused by: java.lang.IllegalStateException: No registered metadata for
> > type "class com.retail_sc.test.entity.Group".
> >at
> > org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
> >at
> > org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:111)
> > ...
> >
> > Best regards Marcel
> >
> >
> >
> > From:   Rick Curtis 
> > To: users@openjpa.apache.org
> > Date:   10.08.2011 18:04
> > Subject:Re: Problems when using "openjpa.MetaDataFactory"
> Property
> >
> >
> >
> > See if setting this property works for you. -->  > name="openjpa.MetaDataFactory"
> > value="org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory/>
> >
> > Thanks,
> > Rick
> >
> >
> > On Wed, Aug 10, 2011 at 10:48 AM, Marcel Urbanek
> > wrote:
> >
> > > Sure.
> > >
> > > My Entity looks like the following:
> > >
> > >@Entity
> > >@Table(name="MPTZZY")
> > >public class Group extends UpdateEntity{
> > >
> > >/*Remark text*/
> > >@Column(name = "TE_RMK",
> > >length=20)
> > >private String  remarkText;
> > >[...]
> > >
> > >
> > > The according Junit Test is the following (EJB-Services are
> implemented
> > > straight forward):
> > >
> > >GroupServiceLocal tempGroupService = (GroupServiceLocal)
> > > initialContext.lookup(GroupServiceLocal.class.getCanonicalName());
> > >Person

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

2011-08-05 Thread Michael Dick
Statement batching is an OpenJPA optimization. By default OpenJPA will try
to use JDBC statement batching. There's a section in the user manual at :
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_stmtbatch.

Depending on the application, statement batching can provide a significant
performance boost. For example inserting several rows to the same table can
be batched, and executed in a single conversation with the database.

If your application updates several different tables, or different parts of
the same table, statement batching provides less of a benefit.

If you believe it will not benefit your app, or you want to remove the
batching from the equation, you can disable batching by adding the following
property to persistence.xml :



Hope this helps,
-mike

On Fri, Aug 5, 2011 at 8:27 AM, M. Walter  wrote:

> Please can anyone explain to me when "batching prepstmnt" occurs? What
> exactly is the cause of this? What are the reasons causing OpenJPA to batch
> statements?
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-of-all-children-is-incremented-in-OneToMany-when-merging-parent-entity-tp6645128p6656525.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: problem with bulk update and @Version annotation

2011-08-04 Thread Michael Dick
IBM provides a feature pack JPA 2.0 which will install on WebSphere version
7. You can find more information the following site:
http://www-01.ibm.com/software/webservers/appserv/was/featurepacks/osgi/

HTH
-mike

On Thu, Aug 4, 2011 at 12:54 AM, f.joe  wrote:

> Hi Mike,
> thanks for your reply.
>
> I have to investigate how move to 2.x version, because my application runs
> on WebSphere 7, that uses openjpa 1.2.x managed by IBM
> Thanks for your mail,
> j
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/problem-with-bulk-update-and-Version-annotation-tp6648211p6651463.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Slice and connection pools

2011-08-03 Thread Michael Dick
Let us know what you find. I don't think we've done much (any)
experimentation with slice + Tomcat's connection pool.

FWIW I did put in a quick update to the manual for the DBDictionary setting.
It should show up in tonight's build.

-mike

On Wed, Aug 3, 2011 at 1:29 PM, RICHARD LUONG  wrote:

> That's correct Mike.
>
> Also, thus far, I could only get OpenJPA slice working with DBCP.  There
> seems to be an issue with using Tomcat Connection Pool.  Once I have more
> time to trace/debug what's going on, I'll post it on a new thread.
>
> Richard.
>
> On Wed, Aug 3, 2011 at 11:01 AM, Michael Dick  >wrote:
>
> > I think Richard's configuration is correct. The only catch, which he
> > pointed
> > out,  is that you do have to specify the DBDictionary to use. Maybe I
> > missed
> > something though?
> >
> > I'm not sure whether having to specify the DBDictionary is the result of
> > the
> > automagic connection pool support, but for the time being we should
> update
> > the documentation to reflect this requirement.
> >
> > In case I missed something, here's the persistence unit from the
> > openjpa-slice module that I used to reproduce the problem :
> > http://pastebin.com/W47zy9ms
> >
> > -mike
> >
> > On Wed, Aug 3, 2011 at 10:05 AM, Pinaki Poddar 
> wrote:
> >
> > > The connection pooling can be configured for each slice as you would do
> > > normally [1] for a single database. The property names however will
> > change.
> > >
> > > 
> > >
> > > However, we have introduced some new mechanics that can configure a
> > > connection pool automagically when commons dbcp in classpath. I do not
> > > think
> > > that this new mechanics have taken Slice connection establishment into
> > > account.
> > >
> > >
> > > [1]
> > >
> > >
> >
> http://openjpa.apache.org/faq.html#FAQ-HowdoIenableconnectionpoolinginOpenJPA%253F
> > >
> > > -
> > > Pinaki Poddar
> > > Chair, Apache OpenJPA Project
> > > --
> > > View this message in context:
> > >
> >
> http://openjpa.208410.n2.nabble.com/Slice-and-connection-pools-tp6643295p6649074.html
> > > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> > >
> >
>


Re: Slice and connection pools

2011-08-03 Thread Michael Dick
I think Richard's configuration is correct. The only catch, which he pointed
out,  is that you do have to specify the DBDictionary to use. Maybe I missed
something though?

I'm not sure whether having to specify the DBDictionary is the result of the
automagic connection pool support, but for the time being we should update
the documentation to reflect this requirement.

In case I missed something, here's the persistence unit from the
openjpa-slice module that I used to reproduce the problem :
http://pastebin.com/W47zy9ms

-mike

On Wed, Aug 3, 2011 at 10:05 AM, Pinaki Poddar  wrote:

> The connection pooling can be configured for each slice as you would do
> normally [1] for a single database. The property names however will change.
>
> 
>
> However, we have introduced some new mechanics that can configure a
> connection pool automagically when commons dbcp in classpath. I do not
> think
> that this new mechanics have taken Slice connection establishment into
> account.
>
>
> [1]
>
> http://openjpa.apache.org/faq.html#FAQ-HowdoIenableconnectionpoolinginOpenJPA%253F
>
> -
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Slice-and-connection-pools-tp6643295p6649074.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


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

2011-08-03 Thread Michael Dick
If you're explicitly locking the entities I can see where a version update
would be appropriate. If you're just merging changes in then it's not clear
why the versions would be updated.

If you could post a testcase that would probably be the most helpful.

-mike

On Wed, Aug 3, 2011 at 10:59 AM, Rick Curtis  wrote:

> Yes, sorry. I noticed it after I sent my response. I don't have a lot of
> experience with OpenJPA locking, but I don't think you want to use the
> pessimistic lock manager. I'd rather get back on the track of figuring out
> why we have the behavior that we do. If you get a ut going I'll take a peek
> at it.
>
>
> On Wed, Aug 3, 2011 at 10:23 AM, M. Walter  wrote:
>
> > Hi Rick,
> >
> > did you read my second posting?
> >
> > --
> >
>
>
>
> --
> *Rick Curtis*
>


Re: problem with bulk update and @Version annotation

2011-08-03 Thread Michael Dick
Hi,

I think you're running into
OPENJPA-1583,
which is fixed in version 2.0.0 and later (but not on 1.2.x). Is moving up
to 2.x an option for you?

-mike


On Wed, Aug 3, 2011 at 5:33 AM, joe falchetto wrote:

> Hello,
> I'm facing a strange problem with the @Version Annotation with field
> property as Timestamp.
> With a bulk update I'll get the following error:
> javax.ejb.EJBException: The bean encountered a non-application exception;
> nSign outested exception is:
>  
> org.apache.openjpa.persistence.ArgumentException: java.util.Date
> incompatible with java.lang.String
> If I change the @Version field property from a Timestamp to an int it works
> fine.
>
> I'm using OpenJPA 1.2.1, OpenEJB 3.1.4 and HSQL 1.8.1 (I have the same
> problem when I use DB2.).
> I build my project with Maven and I enhance the classes with the maven
> plugin.
> I could try to provide a simple testcase if one is needed.
>
> I have created a simple project (starting from openejb sample)  with the
> following classes:
>
> I have a sample JPA entity "Movie" wit the following attribute:
>@Id
>private int id;
>private String director;
>private String title;
>private int year;
>@Version
>private Timestamp lastUpdate;
>
>
> My unit test insert the following 4 objects in the DB:
> id: 1,director=Quentin Tarantino,title:Reservoir Dogs,year:1992
> id: 2,director=Quentin Tarantino,title:Kill Bill,year:2001
> id: 3,director=Joel Coen,title:Fargo,year:1996
> id: 4,director=Joel Coen,title:The Big Lebowski,year:1998
>
> When I call from my unit the stateless session bean method:
>public int singleUpdate(String director) {
>String s = "select m from Movie as  m where
> m.director='"+director+"'";
>Query q = entityManager.createQuery(s);
>List list = q.getResultList();
>for (Iterator iter = list.iterator(); iter.hasNext();) {
>Movie movie = iter.next();
>movie.setDirector("myTestsingleUpdate");
>entityManager.merge(movie);
>
>}
>return list.size();
>}
>
> It successfully updates two records associated to the director=Joel Coen.
> When I call from my unit test the stateless session bean method:
>
>public int bulkUpdate(String director) {
>String s = "update Movie m set m.director = 'bulkUpdate' where
> m.director='"+director+"'";
>Query q = entityManager.createQuery(s);
>return q.executeUpdate();
>}
>
> It should update two records but I'll get the following error:
> est(org.superbiz.injection.jpa.MoviesTest)  Time elapsed: 0.844 sec  <<<
> ERROR!
> javax.ejb.EJBException: The bean encountered a non-application exception;
> nested exception is:
> 
> org.apache.openjpa.persistence.ArgumentException: java.util.Date
> incompatible with java.lang.String
>  at
>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:359)
> at
>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:287)
>  at $Proxy31.bulkUpdate(Unknown Source)
> at org.superbiz.injection.jpa.MoviesTest.test(MoviesTest.java:80)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
>  at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:618)
>  at junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
>  at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
>  at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:120)
>  at junit.framework.TestSuite.runTest(TestSuite.java:228)
> at junit.framework.TestSuite.run(TestSuite.java:223)
>  at
>
> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
> at
>
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
>  at
>
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:146)
> at
>
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
>  at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:618)
>  at
>
> org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
> at $Proxy0.invoke(Unknown Source)
>  at
>
> org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
> at
>
> org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
>  at
> org.apache.maven.surefire.boote

Re: openjpa.Runtime "Unable to locate Transaction Synchronization Registry"

2011-07-29 Thread Michael Dick
I don't have a nice solution for you (at least not yet).

I may have an explanation for the warning that you're getting. The
javaAccessorNotSet can happen if a JNDI namespace is not available. In this
case the JPA code is looking for the Transaction Synchronization Registry in
JNDI, but it's not available in your unit test environment. For what it's
worth, the lookup in question appears to come from the WebSphere JPA
provider, not OpenJPA.

Since you're using generated primary keys you're going to have to get the
value from the database before you can detach the entity. That communication
with the database will trigger a JNDI lookup, and this message will be
logged. For your unit test you can ignore it (unless you want to set up a
JNDI namespace for your unit test).

I don't think this helps with your serialization / DTO question, but the
error message you're getting seems to be benign.

-mike

On Fri, Jul 29, 2011 at 3:39 AM, M. Walter  wrote:

> No there are no exceptions. And enabling openjpa.Log Enhance=TRACE did not
> help either.
>
> But I did some debugging and I could isolate the problem.
> When I persist my entities I do a flush and a refresh in order to return
> the
> entity instance just after the INSERT to the client. This is done because
> the client does not have to explicitly call a business entity finder method
> again to get the entity with the now set primary key back. So my persist
> method does four things:
> em.persist(myEntity);
> em.flush();
> em.refresh(myEntity);
> return myEntity;
>
> Now it shows that this is the problem. If I remove the flush and refresh
> calls the "SEVERE: javaAccessorNotSet" errors disappear in my JUnit tests
> but now I get a stale (meaning the entity has the state BEFORE the INSERT -
> no primary key is set) entity back. I'm not sure whether this is a good
> practice because I do a commit in the middle of the business transaction.
> But the RCP client needs the primary key because after saving the data the
> client has to execute further business methods which need the primary key.
> A
> new remote call to the service facade in order to get the whole entity
> object tree with all relationships converted to DTOs first, serialized,
> shipped over the network and then deserialized again is very costly. But
> maybe you have a nice solution for me? :-)
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-Runtime-Unable-to-locate-Transaction-Synchronization-Registry-tp6626607p6632770.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: openjpa.Runtime "Unable to locate Transaction Synchronization Registry"

2011-07-28 Thread Michael Dick
Hi,

Is there an exception logged with the message? The inner message is an INFO
message, so in itself it should be benign. I'd expect the Transaction
Synchronization Registry to only be available in JEE, so I don't think there
is anything wrong with your environment.

I'm at a loss regarding the javaAccessorNotSet message though. If there is
an exception printed, maybe the stack trace will shed some light on the
problem. It might also be good to enable trace for OpenJPA.Enhance to make
sure the javaagent did enhance your entities.

Hope this helps,

-mike


On Wed, Jul 27, 2011 at 10:39 AM, M. Walter  wrote:

> Does anyone know what's wrong when this error occurs and how I can fix it?
>
> I get this message when I test my EJB DAO with JUnit. I create a new entity
> and persist it using H2 in-memory database. Next I load the entity from the
> database again. When I invoke a getter method from the entity the message
> is
> printed out. The JUnit test is executed with javaagent runtime enhancement.
>
> Here are some loggings:
> 218  resource-local-pu  INFO   [main] openjpa.Runtime - Starting OpenJPA
> 1.2.3-SNAPSHOT
> 331  resource-local-pu  INFO   [main] openjpa.jdbc.JDBC - Using dictionary
> class "org.apache.openjpa.jdbc.sql.H2Dictionary".
> 0 [main] INFO server.persistence.dao.MyDaoBean - Persisting new entity with
> number [638].
> 260 [main] INFO server.persistence.dao.MyDaoBean - Finding entity with
> primary key [1].
>
> >>> now I invoke entity.getNumber() <<<
>
> Jul 27, 2011 5:32:19 PM null null
> SEVERE: javaAccessorNotSet
> 4725  resource-local-pu  INFO   [main] openjpa.Runtime - Unable to locate
> Transaction Synchronization Registry.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-Runtime-Unable-to-locate-Transaction-Synchronization-Registry-tp6626607p6626607.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: release notes for OpenJPA 2.1.1

2011-07-28 Thread Michael Dick
Thanks for letting us know.

I copied the file to the correct location, and the link should be correct
once the mirrors update.

-mike

On Thu, Jul 28, 2011 at 8:06 AM, Georgi Naplatanov  wrote:

> Hi all.
>
> Release notes for OpenJPA 2.1.1 is not available at download page.
>
> page - 
> http://openjpa.apache.org/**downloads.html
> link - http://openjpa.apache.org/**builds/2.1.1/apache-openjpa-2.**
> 1.1/RELEASE-NOTES.html
>
> Fix it, please.
>
> Best regards
> Georgi
>


Re: It can be done in annotations but not in XML?

2011-07-18 Thread Michael Dick
Sorry about that, I missed the email about having OpenJPA generate the XML
(which is pretty cool).

Thanks for the clarification,
-mike

On Mon, Jul 18, 2011 at 5:09 PM, Jason Pyeron  wrote:

> > -Original Message-
> > From: Pinaki Poddar [mailto:ppod...@apache.org]
> > Sent: Monday, July 18, 2011 17:48
> > To: users@openjpa.apache.org
> > Subject: Re: It can be done in annotations but not in XML?
> >
> > I thought (assumed rather) the XML was generated by OpenJPA
> > itself form the annotated entity classes.
> > Jason, can you please confirm that assumption?
>
> Yes, it was generated from openjpa
>
> > If that is the case, then it is a OpenJPA bug?
> > Else it is my bad assumption.
> >
> >
> >
> > -
> > Pinaki Poddar
> > Chair, Apache OpenJPA Project
> > --
> > View this message in context:
> > http://openjpa.208410.n2.nabble.com/It-can-be-done-in-annotati
> ons-but-not-in-XML-tp6596288p6596544.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> -   -
> - Jason Pyeron  PD Inc. http://www.pdinc.us -
> - Principal Consultant  10 West 24th Street #100-
> - +1 (443) 269-1555 x333Baltimore, Maryland 21218   -
> -   -
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> This message is copyright PD Inc, subject to license 20080407P00.
>
>
>
>


Re: It can be done in annotations but not in XML?

2011-07-18 Thread Michael Dick
I'm not sure it's a bug.  A quick read of the XSD in the spec backs up the
parse exception, the id tag can't contain a join column..

Shouldn't the xml be something like this?










-mike

On Mon, Jul 18, 2011 at 3:52 PM, Pinaki Poddar  wrote:

> > Hmmm... I don't think I am crazy here
> nope. I think u just found a bug.
> Please file a JIRA.
>
>
> -
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/It-can-be-done-in-annotations-but-not-in-XML-tp6596288p6596368.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Perfered way to convert JPA2 annotations to a persistence.xml based mapping file?

2011-07-18 Thread Michael Dick
If the tables have already been created you can use OpenJPA's reverse
mapping 
tool.
It will recreate the .java files for you in addition to the XML mapping
file. There's no need to use the generated .java files though.

If you don't have the tables created, you could use the OpenJPA forward
mapping tool
to
create the temporary database. Then use the reverse mapping tool to create
the XML file.

I'm not aware of a tool that writes the XML mapping files without going to a
database, but this should at least get you started.

-mike

On Sun, Jul 17, 2011 at 8:34 PM, Jason Pyeron  wrote:

> What is the perfered way to convert JPA2 annotated entities to an XML
> mapping
> file?
>
> We are using openjpa 2.1.
>
> -Jason
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> -   -
> - Jason Pyeron  PD Inc. http://www.pdinc.us -
> - Principal Consultant  10 West 24th Street #100-
> - +1 (443) 269-1555 x333Baltimore, Maryland 21218   -
> -   -
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> This message is copyright PD Inc, subject to license 20080407P00.
>
>
>


Re: Logging questions

2011-07-13 Thread Michael Dick
On Wed, Jul 13, 2011 at 12:00 PM, Jason Pyeron  wrote:

> > -Original Message-
> > From: Michael Dick [mailto:michael.d.d...@gmail.com]
> > Sent: Wednesday, July 13, 2011 12:53
> > To: users@openjpa.apache.org
> > Subject: Re: Logging questions
> >
> > It looks like you have the log4j-over-slf4j bridge on your
> > classpath. Or some combination of the different logging facilities.
>
> It is possible. But my test case does not have it. I will check deeper on
> this.


FWIW, I created a maven project with just commons-logging and
log4j-over-slf4j on the classpath, and got a very similar error. It sounds
like you have a standalone testcase too, is that something you can send us?


> >
> > So commons-logging detects log4j and tries to use it. Log4j
> > tries to delegate to slf4j, but that fails due to the missing
> > implementation class.
> >
> > Do other parts of your application use log4j or slf4j? If
> > not, can you remove them from the classpath and try 'just'
> > with commons-logging?
> >
>
> There are legacy parts of the system that were designed for other logging
> frameworks, I do not have permission to modify those. I will need to find a
> way
> to force java.util.logging.


I think this is more of a commons-logging behavior than OpenJPA. From
looking at the commons-logging
documentation<http://commons.apache.org/logging/commons-logging-1.1.1/guide.html#Configuration>it
will look for log4j on the classpath before trying java.util.logging.

The doc doesn't spell it out, or at least I couldn't find it,  but you can
add a commons-logging.properties file to the classpath. The properties file
should have this entry :
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger

In my simple test it looks like it used Jdk4Logging.  I don't know whether
it will play well with the legacy parts of your system, but it's worth a
try.

Hope this helps,
-mike

 


Re: Logging questions

2011-07-13 Thread Michael Dick
It looks like you have the log4j-over-slf4j bridge on your classpath. Or
some combination of the different logging facilities.

So commons-logging detects log4j and tries to use it. Log4j tries to
delegate to slf4j, but that fails due to the missing implementation class.

Do other parts of your application use log4j or slf4j? If not, can you
remove them from the classpath and try 'just' with commons-logging?

-mike

On Tue, Jul 12, 2011 at 1:36 PM, Jason Pyeron  wrote:

> > -Original Message-
> > From: Rick Curtis [mailto:curti...@gmail.com]
> > Sent: Tuesday, July 12, 2011 14:00
> > To: users@openjpa.apache.org
> > Subject: Re: Logging questions
> >
> > What do you have set for a configuration property? Have you
> > tried openjpa.Log=commons?
>
> 
>
>
> value="loaded(DetachedStateField=false)"/>
>
>
>
>
> value="jdbc:oracle:thin:@localhost:1521/XE"/>
> value="oracle.jdbc.driver.OracleDriver"/>
> value="fepldev_web"
> />
> value="password" />
> value="join" />
> value="native(ForeignKeys=true) " />
>
>
> 
>
>
> Also worth noting, it burps out at the very start:
>
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
> details.
> log4j:WARN No appenders could be found for logger (openjpa.Runtime).
> log4j:WARN Please initialize the log4j system properly.
>
> >
> > On Tue, Jul 12, 2011 at 12:48 PM, Jason Pyeron
> >  wrote:
> >
> > > > -Original Message-
> > > > From: Rick Curtis [mailto:curti...@gmail.com]
> > > > Sent: Tuesday, July 12, 2011 12:22
> > > > To: users@openjpa.apache.org
> > > > Subject: Re: Logging questions
> > > >
> > > > Jason -
> > > >
> > > > Sorry about the slow reply, I must have missed this one somehow.
> > > >
> > > > > 1. Is it possible to (dynamically) change the logging
> > > > levels at runtime?
> > > > No, I don't believe so.
> > > >
> > > > > 2. Could someone elaborate more on the usage of
> > java.util.logging
> > > > > by
> > > > setting to value to "commons"?
> > > > What more are you looking for?
> > >
> > > Hmm.. It does not seem to use j.u.l for logging when set to
> > commons on
> > > Sun Java
> > > 1.6 64 bit.
> > >
> > > My formatter would output like:
> > >
> > > Jul 12, 2011 12:32:10 PM
> > org.apache.coyote.http11.Http11BaseProtocol
> > > init
> > > INFO: Initializing Coyote HTTP/1.1 on http-8080
> > >
> > > But I am getting interspersed [double CR added for clarity]:
> > >
> > > 3500  localhost  WARN   [main] openjpa.MetaData - Found
> > duplicate generator
> > > "seq" in "class
> > >
> > xxx.RecycledVoucherCheckFile".
> > > Ignoring.
> > >
> > >
> > > Jul 12, 2011 1:43:58 PM
> > > xxx.TestClaimModels setUp
> > > FINE: factory created
> > >
> > >
> > > 203  localhost  INFO   [main] openjpa.Runtime - Starting OpenJPA
> > > 2.1.0-SNAPSHOT
> > >
> > >
> > > 484  localhost  INFO   [main] openjpa.jdbc.JDBC - Using
> > dictionary class
> > > "org.apache.openjpa.jdbc.sql.OracleDictionary".
> > >
> > >
> > > Jul 12, 2011 1:44:07 PM
> > > xxx.TestClaimModels setUp
> > > FINE: em created
> > >
> > >
> > > Jul 12, 2011 1:44:07 PM
> > > xxx.TestClaimModels
> > > testListAllObjects
> > > INFO: class
> > > xxx.AdditionalErrorInfo:
> > > before
> > >
> > >
> > > 14078  localhost  TRACE  [main] openjpa.jdbc.SQL -  > >
> > >
> > >
> > >
> > >
> > > >
> > > > On Wed, Jun 29, 2011 at 3:55 PM, Jason Pyeron 
> > > > wrote:
> > > >
> > > > > Using 2.1.x I have 2 questions I was unable to google for an
> > > > > answer after reading the manual.
> > > > >
> > > > > 1. Is it possible to (dynamically) change the logging
> > > > levels at runtime?
> > > > >
> > > > > 2. Could someone elaborate more on the usage of
> > > > java.util.logging by
> > > > > setting the value to "commons"?
> > > > >
> > > > > -Jason
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> -   -
> - Jason Pyeron  PD Inc. http://www.pdinc.us -
> - Principal Consultant  10 West 24th Street #100-
> - +1 (443) 269-1555 x333Baltimore, Maryland 21218   -
> -   -
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> This message is copyright PD Inc, subject to license 20080407P00.
>
>
>
>


Re: Entity generation is very time consuming

2011-07-13 Thread Michael Dick
I don't have any general tips that will apply to every situation, so here
come more questions.

How are you loading the rows (one big query, or several smaller ones)?

Do you have a lot of relationships in your entities (the resulting joins can
slow things down).

Do you see a lot of connections being obtained from the connection pool?

-mike

On Wed, Jul 13, 2011 at 10:15 AM, M. Walter  wrote:

> I have an Oracle 10g database and in the JEE application I use
> OpenJPA-1.2.3-SNAPSHOT (which is shipped with IBM WebSphere 7 application
> server). I'm loading 60.000 rows from a table with some booleans, strings,
> numbers and timestamps. Nothing big and no blobs and things like that. The
> generation of the corresponding JPA entities takes 24 seconds. This is very
> long in my opinion. Is there any possibility to tune and speed things up
> considerably? I think 60.000 entities should not be that much data so I
> have
> to get a cup of coffee every time I trigger the select...
>
> Do you have any hints for me in order to increase performance? Thank you!
>
> P.S.: Unfortunately I can't upgrade to JPA 2.0, only JPA 1.0 features
> allowed.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Entity-generation-is-very-time-consuming-tp6579389p6579389.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Enhancement skipping field

2011-07-08 Thread Michael Dick
I think we can ignore the warning about Phone_ for now. The enhancer will
not automatically ignore the MetaModel classes, but it shouldn't be hurting
anything.

I haven't been able to reproduce the other warning. If your project is
available on github please post a link - that might be the quickest way to
get to the bottom of the problem.

If not , can you post the settings you use when running the enhancer? It
sounds like you're using the maven plugin, and it'd help us if we could run
the same way.

-mike
On Thu, Jul 7, 2011 at 5:15 PM, Matthew Goodson
wrote:

> Yeah _ classes don't need to enhanced but the plugin doesn't
> exclude
> them but it doesn't affect the application so I'm not too worried.
> Its the Phone.id field that is not being enhanced that's causing my
> problem.
> Thanks
>
> On Fri, Jul 8, 2011 at 9:35 AM, Kevin Sutter  wrote:
>
> > Hi Matthew,
> > Not sure which maven plugin or ant script is being used for your
> build-time
> > enhancement, but can it be modified to exclude the generated _
> > classes?  These should not be run through the enhancer.
> >
> > Also, just to verify...  You are generating these _ classes on
> > purpose, correct?  These underscored classes are generated metamodel
> > classes
> > in support of the Metamodel and Criteria APIs.  Is your application using
> > one or both of these new features in JPA 2.0?  Just checking...
> >
> > Thanks,
> > Kevin
> >
> > On Thu, Jul 7, 2011 at 4:27 PM, Matthew Goodson
> > wrote:
> >
> > > Hi,
> > >
> > > Kevin: We're using maven and it is picking up the Phone_ class and
> > > generating the warning
> > >
> > > here's the link for the uuid class that we're using
> > >
> > >
> >
> https://github.com/stephenc/eaio-uuid/blob/master/src/main/java/com/eaio/uuid/UUID.java
> > >
> > > And the persistence xml...
> > >
> > > 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_2_0.xsd";
> > >  version="2.0">
> > >  
> > >
> > >
> >
> org.apache.openjpa.persistence.PersistenceProviderImpl
> > >
> > >
> > >
> > >com.spidertracks.aviator.model.Persistable
> > >com.spidertracks.aviator.model.UuidEntity
> > >
> > >
> > >
> > >com.spidertracks.aviator.model.cluster.ClusterRegion
> > >com.spidertracks.aviator.model.cluster.SpiderRegion
> > >
> > >
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.security.AviatorRememberMeToken
> > >
> > >
> > >
> >  com.spidertracks.aviator.model.sms.PhoneValidationMessage
> > >com.spidertracks.aviator.model.sms.ReceivedSmsMessage
> > >com.spidertracks.aviator.model.sms.SentSmsMessage
> > >com.spidertracks.aviator.model.sms.SmsMessage
> > >com.spidertracks.aviator.model.sms.SosClosedMessage
> > >
> > >
> >
> com.spidertracks.aviator.model.sms.SosInvalidResponseMessage
> > >com.spidertracks.aviator.model.sms.SosMessage
> > >com.spidertracks.aviator.model.sms.SosTierOneMessage
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.sms.SosTierOneReopenedUserMessage
> > >com.spidertracks.aviator.model.sms.SosTierTwoMessage
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.sms.SosTierTwoReopenedUserMessage
> > >
> >  com.spidertracks.aviator.model.sms.SosTierTwoUserMessage
> > >
> > >
> > >
> > >com.spidertracks.aviator.model.sos.ContactedPerson
> > >com.spidertracks.aviator.model.sos.OpenHistory
> > >com.spidertracks.aviator.model.sos.SoS
> > >
> > >
> > >com.spidertracks.aviator.model.spider.Spider
> > >
> > >
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.spider.message.AlertAcknowlege
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.spider.message.ConfigMessageUpdate
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.spider.message.DistanceSettings
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.spider.message.MobileTerminatedConfirmation
> > >
> > >
> com.spidertracks.aviator.model.spider.message.SpiderUpdate
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.spider.message.SpiderwatchSettings
> > >
> > >
> > >
> >
> com.spidertracks.aviator.model.spider.message.TimeDistanceSettings
> > >
> > >
> com.spidertracks.aviator.model.spider.message.TimeSettings
> > >
>  com.spidertracks.aviator.model.spider.message.WatchOff
> > >com.spidertracks.aviator.model.spider.message.WatchOn
> > >
> > >
> > >
> > >com.spidertracks.aviator.model.user.ContactLink
> > >com.spidertracks.aviator.model.user.Address
> > >com.spidertracks.aviator.model.user.Customer
> > >
> > >
> com.spidertracks.aviator.model.user.EmailConfirmationToken
> > >com.spidertracks.aviator.model.user.HashedUserToken
> > >com.spidertracks.aviator.model.user.InvitedPerson
> > >
>  com.spidertracks.aviator.model.user.PasswordResetToken
> > >com.spidertracks.aviator.model.user.Person
> > >com.spidertracks.aviator.model.user.User
> > >

Re: How to store a string array as a string array using jpa?

2011-07-08 Thread Michael Dick
Here's what I've seen (a slight addition to Fay's post in Nabble)

ElementCollection may be used with Collections, or Maps. It should not be
used with an array - like the original poster's example.

PersistentCollection is specific to OpenJPA and may be used with an array
(int[], String[]), or a Collection.

PersistentMap is also specific to OpenJPA and may be used with Maps.

-mike

2011/7/8 Håkon Sagehaug 

> Hi
>
> I use something like this
>
> @PersistentCollection
>private List subEntries = new LinkedList();
>
> Can also be used for String arrays. I think that PersistentCollection is
> JPA
> specific, but there is a annotaion called ElementCollection, from the 2.0
> spec. See this thread[1] for more info
>
> [1]
>
> http://openjpa.208410.n2.nabble.com/ElementCollection-and-PersistentCollection-td4737753.html
>
>
>
> On 8 July 2011 07:33, Suseendran.P  wrote:
>
> > Thank you so much for ur reply..i go through the document..
> >
> > First i have to say i'm very new to JPA..,
> > i'm using javax.persistence related packages to annotate my class..means
> > not
> > using org.apache.openjpa.persistence related packages..in that document
> > they
> > gave JPA is not externalized can i mix these two packages in single
> class..
> >
> >  i constructed my class like this..
> >
> > @Entity
> > public class Station  {
> >
> >@Id
> >@GeneratedValue(strategy = GenerationType.AUTO)
> >private long id;
> >
> >private String[] names;
> >
> >// setter and getter methods
> > }
> >
> > Now what annotation i ve to give to store this array of string names in
> > single row in Mysql database..
> >
> > --
> > View this message in context:
> >
> http://openjpa.208410.n2.nabble.com/How-to-store-a-string-array-as-a-string-array-using-jpa-tp209875p6561347.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >
>


Re: merge() doesn't refresh many-to-one members unless attribute is called explicitly?

2011-06-21 Thread Michael Dick
Off the top of my head I'd say that the first case will perform slightly
better.  In the first case OpenJPA will get a single connection to the
database, in the second case we'll get two (one for merge, and another for
refresh). You could change this behavior with the
openjpa.ConnectionRetainMode property, but that might have other
implications depending on your application.

Regards,
-mike

--
View this message in context: 
http://openjpa.208410.n2.nabble.com/merge-doesn-t-refresh-many-to-one-members-unless-attribute-is-called-explicitly-tp6494445p6500031.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: merge() doesn't refresh many-to-one members unless attribute is called explicitly?

2011-06-20 Thread Michael Dick
Thanks for the thorough description of the problem!

The problem here is that you're merging a new instance of ToBeMerged, which
has a relationship to a detached RelatedObject.  The merge operation isn't
cascaded by default, so the rules become a little muddy.

Adding CascadeType.MERGE will also solve the problem, is that an acceptable
solution for you?

-mike

On Sun, Jun 19, 2011 at 9:17 PM, twelveeighty wrote:

> Since this sounds like a basic operation that fails for me, I'm inclined to
> think I'm doing something wrong, but I can't find anything similar in the
> FAQ or online, so please tell me what I am missing here.
>
> If I use merge() to insert a new entity that has a many-to-one relationship
> to another entity, it gets created OK, but the *returned* object from
> merge() has the related record defined with ONLY its primary key filled in,
> all other attributes on the related record are null. To make it even
> weirder: if I call "get()" while the object is still
> attached, everything is fine.
>
> Here are the details:
>
> OpenJPA version 2.1.1
>
> @Entity
> RelatedObject {
>  @Id
>  private int relatedObjectId;
>
>  @Column(nullable=false, length=255)
>  private String shouldNeverBeNull;
> }
>
> @Entity
> ToBeMergedObject {
>  @Id
>  private int toBeMergedObjectId;
>
> // @ManyToOne(optional=false, cascade=CascadeType.REFRESH) - tried both,
> didn't make a difference
>  @ManyToOne(optional=false)
>  @JoinColumn(name="relatedObjectId", nullable=false, updatable=false)
>  private RelatedObject relatedObject;
> }
>
> In the database, there is an existing row for RelatedObject with values (1,
> 'Some String'). An corresponding instance has been preloaded and has been
> detached at some point, let's call this detached instance:
> preloadedRelatedObject.
>
> Now, create a new ToBeMergedObject (still outside an EntityManager's
> context)
>
> ToBeMergedObject toBeMerged = new ToBeMergedObject();
>
> toBeMerged.setRelatedObject(preloadedRelatedObject);
>
> CASE 1: Create a context and merge the new entity:
>
> EntityManager em = [...]
>
> em.getTransaction().begin();
> ToBeMergedObject afterMerge = em.merge(toBeMerged);
> em.getTransaction().commit();
> em.close();
> if (afterMerge.getRelatedObject().getShouldNeverBeNull()==null) {
>  log.error("HOW IS THIS POSSIBLE?");
> }
>
> CASE 2: Create a context and merge the new entity, but make a (useless)
> call
> to getRelatedObject() before the em.close();
>
> EntityManager em = [...]
>
> em.getTransaction().begin();
> ToBeMergedObject afterMerge = em.merge(toBeMerged);
> em.getTransaction().commit();
> logger.debug("Some useless call: " +
> afterMerge.getRelatedObject().getShouldNeverBeNull());
> em.close();
> if (afterMerge.getRelatedObject().getShouldNeverBeNull()==null) {
>  log("doesn't happen");
> } else {
>  log("NOW IT IS AS EXPECTED - getShouldNeverBeNull() returns a value");
> }
>
> As I mention in the definition of the many-to-one pseudo code, I have tried
> with cascade=CascadeType.REFRESH but that makes no difference.
>
> Why is it that with a call to the getShouldNeverBeNull() INSIDE the "scope"
> of the EntitiyManager that the object gets returned "fully loaded", but
> without it, it doesn't?
>
> I appreciate any help you folks can give me on this one.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/merge-doesn-t-refresh-many-to-one-members-unless-attribute-is-called-explicitly-tp6494445p6494445.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Dynamic Enhancement not working on Oracle JDK/Linux

2011-06-16 Thread Michael Dick
I would have thought that setting JAVA_HOME would have worked. Unfortunately
I haven't done a lot with thy the DynamicEnhancerAgent though. I'm glad the
javaagent is mostly working for you though.

I use the agent when running unit tests in eclipse too. I use a string
substitution to shorten the string I have to type, but I still have to
remember to add it to the run configuration.

-mike

On Thu, Jun 16, 2011 at 9:01 AM, Harald Wellmann wrote:

> Hi Mike,
>
> yes, I had to switch to the agent now, as the Dynamic Enhancer did not work
> for me in all cases even with the symlink workaround (probably because some
> Entity classes were loaded before the EMF was created, but I'm using the
> Spring Test Context, and I can't really control what's going on behind the
> scenes in Spring.)
>
> I need my entity classes to work with multiple providers, so I can't use
> Build Time enhancement.
>
> Using the agent is a bit inconvenient when running JUnit tests from
> Eclipse, and I don't really want to enable it globally.
>
> Regarding, the java.home issue:  I'm really talking about the system
> property java.home, not about the environment variable JAVA_HOME. I tried
> setting both, but that didn't work.
>
> Regards,
> Harald
>
>  Original-Nachricht 
> > Datum: Thu, 16 Jun 2011 08:50:33 -0500
> > Von: Michael Dick 
> > An: users@openjpa.apache.org
> > Betreff: Re: Dynamic Enhancement not working on Oracle JDK/Linux
>
> > Hi Harald,
> >
> > I don't think the VirtualMachine class (the class we're looking for in
> > tools.jar) has moved. I compared 1.6.0_22 and 1.6.0_25 and it's in the
> > same
> > location - JDK_HOME/lib/tools.jar.
> >
> > The problem here is that java.home is pointing to the JRE location
> instead
> > of the JDK location (which is what we've been doing in developing
> > OpenJPA).
> >
> > This looks like something we can fix by swizzling the classpath, but the
> > documentation does indicate that you need a JDK, or SDK to run :
> >  2.4.  Enhancing Dynamically at Runtime
> >
> > If a javaagent is not provided via the command line and OpenJPA is
> running
> > on the Oracle 1.6 SDK or IBM 1.6 JDK (SR8+), OpenJPA will attempt to
> > dynamically load the Enhancer that was mentioned in the previous section.
> > This support is provided as an ease of use feature and it is not
> > recommended
> > for use in a production system. Using this method of enhancement has the
> > following caveats:
> >
> > 
> >
> > It doesn't mention the issue about JAVA_HOME though - we'll have to get
> > that
> > updated.
> >
> > In the mean time, can you use a javaagent instead?
> >
> > -mike
> >
> >
>
> --
> NEU: FreePhone - kostenlos mobil telefonieren!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
>


Re: Dynamic Enhancement not working on Oracle JDK/Linux

2011-06-16 Thread Michael Dick
Hi Harald,

I don't think the VirtualMachine class (the class we're looking for in
tools.jar) has moved. I compared 1.6.0_22 and 1.6.0_25 and it's in the same
location - JDK_HOME/lib/tools.jar.

The problem here is that java.home is pointing to the JRE location instead
of the JDK location (which is what we've been doing in developing OpenJPA).

This looks like something we can fix by swizzling the classpath, but the
documentation does indicate that you need a JDK, or SDK to run :
 2.4.  Enhancing Dynamically at Runtime

If a javaagent is not provided via the command line and OpenJPA is running
on the Oracle 1.6 SDK or IBM 1.6 JDK (SR8+), OpenJPA will attempt to
dynamically load the Enhancer that was mentioned in the previous section.
This support is provided as an ease of use feature and it is not recommended
for use in a production system. Using this method of enhancement has the
following caveats:



It doesn't mention the issue about JAVA_HOME though - we'll have to get that
updated.

In the mean time, can you use a javaagent instead?

-mike


On Thu, Jun 16, 2011 at 8:21 AM, Harald Wellmann wrote:

> There's a problem with setting up dynamic enhancement for OpenJPA 2.1.0
> with recent Oracle JDKs on Linux, related to the java.home system property.
>
> org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar()
> attempts to load the tools.jar from ${java.home}/lib/tools.jar.
>
> The problem is that even when running under the JDK, java.home points to
> /usr/lib/jvm/java-6-sun/jre instead of /usr/lib/jvm/java-6-sun.
>
> Just to rule out that Ubuntu's packaging might cause the problem, I
> downloaded the latest JDK 1.6.0_24, installed it in my home folder and
> ran a System.println(System.getProperty("java.home")  both from
> [java_install]/bin/java and [java_install]/jre/bin/java, and in both
> cases, the result was [java_install]/jre.
>
>
> So it appears the special case
> if (JavaVendors.getCurrentVendor().isIBM()) {
>
> in findToolsJar() is now also required for Oracle's JDK.
>
> This looks like a bug or at least an incompatible change in the JDK to
> me, but then again, the structure of a JDK installation is vendor
> dependent, and I'm not sure that OpenJPA's lookup logic is failsafe.
>
> For now, I just created a symlink in my JDK so that OpenJPA finds
> tools.jar under .../jre/lib.
>
> Are there any better solutions? Should I file an issue in JIRA?
>
> Regards,
> Harald
>
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>


Re: Speeding up commit

2011-06-15 Thread Michael Dick
Unfortunately we don't have a good answer for your use case. I spent a
little (very little) time looking into removing the proxies altogether and
it wasn't as simple as just putting the non proxies into the entity.

There should be a jira created for this use case, but I haven't been able to
find one. Do you have a JIRA acount, and would you mind opening one?

-mike

On Wed, Jun 15, 2011 at 9:52 AM, Aron Lurie wrote:

>  We also need the proxies for for managed entities to track the state of
>> non
>> primitives (Dates, collections etc.).
>>
> So in my application, I know that the state of the non primitives will not
> be changing. All I need OpenJPA to do is extract the value of the
> non-primitive once when it is creating its insert statement.
>
>
>  It will not proxy with for AutoDetachType.NONE.
>>
> I have already set this property, and it allows me to close the entity
> manager much faster because it does not bother detaching the proxies, but it
> still attaches proxies during commit, so commit does not run any faster.
>
> -Aron
>
>
> On 6/15/2011 10:37 AM, Michael Dick wrote:
>
>> Rick's right on both counts. TrackChanges doesn't eliminate proxies - it
>> should just make them no-op.
>>
>> We also need the proxies for for managed entities to track the state of
>> non
>> primitives (Dates, collections etc.). I don't think we have code in place
>> that falls back and does a more thorough comparison if the proxies are not
>> found though.
>>
>> Pinaki,
>>
>> The code changes are definitely untested - it's currently breaks the
>> TestEnumToKernelConstantMappings test (which is rather banal, but probably
>> there for a good reason).
>>
>> I'm not sure what you mean about not having a regression test environment.
>> This problem would be found in a rather quick maven build. I understand
>> not
>> having multiple databases available, but running the regression bucket
>> with
>> derby should be doable.
>>
>> You can skip the long running locking tests with this arg:
>> -Dsurefire.excludes.locking=**, if time is a concern.
>>
>> -mike
>>
>> On Wed, Jun 15, 2011 at 9:11 AM, Rick Curtis  wrote:
>>
>>  Javadoc from ProxyManagerImpl
>>>
>>>/**
>>> * Whether proxies produced by this factory will use {@link
>>> ChangeTracker}s
>>> * to try to cut down on data store operations at the cost of some
>>> extra
>>> * bookkeeping overhead. Defaults to true.
>>> */
>>>public boolean getTrackChanges() {
>>>return _trackChanges;
>>>}
>>>
>>> It sounds like this property is used to determine whether the proxies are
>>> tracking changes... not to toggle the creation. Adding another property
>>> to
>>> the ProxyManager to not use proxies from the get-go makes sense to me.
>>>
>>> On Wed, Jun 15, 2011 at 8:58 AM, Kevin Sutter
>>>  wrote:
>>>
>>>  Hi guys,
>>>> Shouldn't this property setting turn off the proxy usage?
>>>>
>>>> 
>>>>
>>>> That's the way I read the documentation, but it doesn't seem to work
>>>> that
>>>> way.  We still get the proxies created.  Actually, I don't see much
>>>> difference in processing whether this is set to True or False.  Is this
>>>> a
>>>> bug, or am I reading the documentation wrong?
>>>>
>>>> Thanks,
>>>> Kevin
>>>>
>>>> On Tue, Jun 14, 2011 at 7:53 PM, Rick Curtis
>>>>  wrote:
>>>>
>>>>  Aren't proxies also used to track changes while a persistence context
>>>>>
>>>> is
>>>
>>>> active?
>>>>>
>>>>> Rick Curtis
>>>>>
>>>>>
>>>
>>> --
>>> *Rick Curtis*
>>>
>>>
>


Re: Speeding up commit

2011-06-15 Thread Michael Dick
Rick's right on both counts. TrackChanges doesn't eliminate proxies - it
should just make them no-op.

We also need the proxies for for managed entities to track the state of non
primitives (Dates, collections etc.). I don't think we have code in place
that falls back and does a more thorough comparison if the proxies are not
found though.

Pinaki,

The code changes are definitely untested - it's currently breaks the
TestEnumToKernelConstantMappings test (which is rather banal, but probably
there for a good reason).

I'm not sure what you mean about not having a regression test environment.
This problem would be found in a rather quick maven build. I understand not
having multiple databases available, but running the regression bucket with
derby should be doable.

You can skip the long running locking tests with this arg:
-Dsurefire.excludes.locking=**, if time is a concern.

-mike

On Wed, Jun 15, 2011 at 9:11 AM, Rick Curtis  wrote:

> Javadoc from ProxyManagerImpl
>
>/**
> * Whether proxies produced by this factory will use {@link
> ChangeTracker}s
> * to try to cut down on data store operations at the cost of some extra
> * bookkeeping overhead. Defaults to true.
> */
>public boolean getTrackChanges() {
>return _trackChanges;
>}
>
> It sounds like this property is used to determine whether the proxies are
> tracking changes... not to toggle the creation. Adding another property to
> the ProxyManager to not use proxies from the get-go makes sense to me.
>
> On Wed, Jun 15, 2011 at 8:58 AM, Kevin Sutter  wrote:
>
> > Hi guys,
> > Shouldn't this property setting turn off the proxy usage?
> >
> > 
> >
> > That's the way I read the documentation, but it doesn't seem to work that
> > way.  We still get the proxies created.  Actually, I don't see much
> > difference in processing whether this is set to True or False.  Is this a
> > bug, or am I reading the documentation wrong?
> >
> > Thanks,
> > Kevin
> >
> > On Tue, Jun 14, 2011 at 7:53 PM, Rick Curtis  wrote:
> >
> > > Aren't proxies also used to track changes while a persistence context
> is
> > > active?
> > >
> > > Rick Curtis
> > >
> >
>
>
>
> --
> *Rick Curtis*
>


Re: AW: openjpa build time enhance using maven plugin DOESN'T WORK

2011-06-08 Thread Michael Dick
I'm glad its working for you. The way I read the docs is that the warning
will come up if you do not have a LoadTimeWeaver configured (and it's safe
to ignore when it does happen).

I don't have a Spring environment handy to double check this though. If you
saw the opposite behavior I'm happy to take your word for it and make the
warning an error.

-mike

On Tue, Jun 7, 2011 at 1:24 PM, infinity2heaven
wrote:

> I had LoadTimeWeaver set in spring config. After looking at Spring docs and
> openjpa docs, it's clear now.
>
> Buildtime enhancing working now. Thank you.
>
> Perhaps, you could convert  http://openjpa.apache.org/integration.htmlthis
> warning  to an ERROR in a future release? It would have saved several
> hours.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-build-time-enhance-using-maven-plugin-DOESN-T-WORK-tp6446547p6450836.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: AW: openjpa build time enhance using maven plugin DOESN'T WORK

2011-06-07 Thread Michael Dick
It looks to me like the unenhanced classes are being loaded with Spring. 

Can you use the same jar / class files in a standalone JSE environment? 

It might also be good to double check your Spring configuration. You should
not have a LoadTimeWeaver specified when using OpenJPA. 

-mike

--
View this message in context: 
http://openjpa.208410.n2.nabble.com/openjpa-build-time-enhance-using-maven-plugin-DOESN-T-WORK-tp6446547p6450703.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: AW: openjpa build time enhance using maven plugin DOESN'T WORK

2011-06-07 Thread Michael Dick
At least the tool is running.

The easiest way to verify that the classes were enhanced is to decompile
them and see if they implement the PersistenceCapable interface. Javap works
fine for this.

If your classes do not implement PersistenceCapable, try adding this to
persistence.xml to enable enhancement logging :
   

Then you should see something like this in your maven build :
252  BeanValidation  TRACE  [main] openjpa.Enhance - Enhancing type "class
org.apache.openjpa.example.gallery.model.Location" loaded by
java.net.URLClassLoader@1cc0a0f.
387  BeanValidation  TRACE  [main] openjpa.Enhance - Enhancing type "class
org.apache.openjpa.example.gallery.model.Album" loaded by
java.net.URLClassLoader@1cc0a0f.
433  BeanValidation  TRACE  [main] openjpa.Enhance - Enhancing type "class
org.apache.openjpa.example.gallery.model.Creator" loaded by
java.net.URLClassLoader@1cc0a0f.
499  BeanValidation  TRACE  [main] openjpa.Enhance - Enhancing type "class
org.apache.openjpa.example.gallery.model.Image" loaded by
java.net.URLClassLoader@1cc0a0f.

If the entities do implement PersistenceCapable, then there's a different
problem.

hope this helps,
-mike

On Tue, Jun 7, 2011 at 10:22 AM, infinity2heaven
wrote:

> just did that and get the same error:
> "This configuration disallows runtime optimization "
>
> How can I check if my .class files are actually enhanced?
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-build-time-enhance-using-maven-plugin-DOESN-T-WORK-tp6446547p6450082.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: AW: openjpa build time enhance using maven plugin DOESN'T WORK

2011-06-07 Thread Michael Dick
I took a look at the openjpa build where we also use this plugin. It looks
like the auto-detection of persistence.xml isn't working for the enhance
goal, but works for the enhance-tests goal. I'm not terribly familiar with
the plugin code though so I might be all wet.

Can you try adding the persistence.xml location to your pom file? Something
like this should work.
 
${project.basedir}/src/main/resources/META-INF/persistence.xml

-mike

On Tue, Jun 7, 2011 at 9:36 AM, infinity2heaven
wrote:

> I'll take my original statement back. The original goal is a "success"
> build
> but when tests are run, it errors that classes are not enhanced.
>
>  --- openjpa-maven-plugin:1.2:enhance (default-cli) @ xxx.yyy ---
> [INFO]
> 
> [INFO] BUILD SUCCESS
>
> For the second module, I can't even run the enhancer.
>
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-build-time-enhance-using-maven-plugin-DOESN-T-WORK-tp6446547p6449900.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: AW: openjpa build time enhance using maven plugin DOESN'T WORK

2011-06-07 Thread Michael Dick
What's different between the working module, and the broken one?

You've checked that persistence.xml is on the classpath. Is it in
src/main/resources or src/test/resources, or some other location?

-mike

On Tue, Jun 7, 2011 at 8:08 AM, infinity2heaven
wrote:

> The issue still occurs in my end. Unfortunately, our dev environment has
> come
> to a standstill with RuntimeEnhancement not working and build time
> enhancement not working as specified.
>
> If anyone else has any ideas, appreciate it.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/openjpa-build-time-enhance-using-maven-plugin-DOESN-T-WORK-tp6446547p6449473.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Native SQL Query

2011-06-03 Thread Michael Dick
Which properties do you have in persistence.xml?

A reply on Nabble (not accepted by the mailing list yet) asserts that this
only happens with slice. If that's the case we can look into reproducing the
problem outside of your container environment. 

Thanks
-mike

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


Re: Padding of CHAR(n) columns with trailing spaces

2011-06-01 Thread Michael Dick
In general the contents of the entity should match what we get back from the
JDBC driver. I don't think OpenJPA intentionally pads or trims the contents
of a String (although you're seeing otherwise). 

That said, DB2 does not differentiate between 'abc' and 'abc   '. So
something like this will work :
INSERT INTO s (name) VALUES ('abc   ') 
SELECT * FROM s WHERE name = 'abc'  // returns the row you just inserted. 

hth
-mike 





--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Padding-of-CHAR-n-columns-with-trailing-spaces-tp6364510p6428535.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Query cache eviction problem with InheritanceType.TABLE_PER_CLASS

2011-05-23 Thread Michael Dick
Hi Oleg,

I don't think there's a workaround available. This sounds like a good
candidate for an improvement though. Could you open a JIRA
issue,
and vote for it?

The model you listed in your first email to the list should reproduce the
problem, but if you can include a unit test as well that will probably
help.

-mike

On Fri, May 20, 2011 at 2:04 AM, LYALIKOV, OLEG (OLEG)** CTR ** <
oleg.lyali...@alcatel-lucent.com> wrote:

> Thanks for reply Kevin.
> Actually there are no any exceptions or errors.
>
> Imagine situation: you have a query "SELECT x FROM A WHERE x.title = 'Some
> title'". You execute this query a lot of times so openjpa can return cached
> query result (I assume this is QueryCache).
>
> But then you for example create new object of type B.
> After create openjpa checks cached queries and finds query "SELECT x FROM A
> WHERE x.title = 'Some title'" which access path (field _accessPathClassNames
> in QueryKey class) contains class A and class Base and this access path
> intersects with access path of create query (it contains class B and class
> Base).
> So openjpa decides to remove query "SELECT x FROM A WHERE x.title = 'Some
> title'" result from cache and when you run this query next time openjpa
> accesses database.
>
> But entity Base doesn't have own table, its fields are contained as in
> table A as in table B and tables A and B don't intersect.
> So decision to remove query "SELECT x FROM A WHERE x.title = 'Some title'"
> result from cache after creating object of class B seems wrong to me.
>
> Openjpa considers entities A and B intersect through their base persistent
> entity Base but actually they don't intersect.
>
> Thanks
> Oleg
>
> -Original Message-
> From: Kevin Sutter [mailto:kwsut...@gmail.com]
> Sent: Thursday, May 19, 2011 7:30 PM
> To: users@openjpa.apache.org
> Subject: Re: Query cache eviction problem with
> InheritanceType.TABLE_PER_CLASS
>
> HI Oleg,
> Can you post the specific exception or error condition you are referring
> to?  OpenJPA utilizes several caches.  It sounds like you might be
> referring
> to the QuerySQLCache not being able to cache the generated SQL.  This is
> different from the QueryCache which caches the results of various Queries.
> Just trying to clarify which cache you are experiencing problems with.
>
> Thanks,
> Kevin
>
> On Thu, May 19, 2011 at 7:28 AM, LYALIKOV, OLEG (OLEG)** CTR ** <
> oleg.lyali...@alcatel-lucent.com> wrote:
>
> > Hello,
> > I'm using openjpa-2.0.0 and have some base class
> >
> > @Entity
> > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> > public abstract class Base { ... }
> >
> > and also some inheritors
> >
> > @Entity
> > @Inheritance(strategy = InheritanceType.JOINED)
> > public class A extends Base { ... }
> >
> > @Entity
> > @Inheritance(strategy = InheritanceType.JOINED)
> > public class B extends Base { ... }
> >
> > Base class has some fields which are used as in A as in B class but these
> > fields are in separate tables (for A and B class) with no common table.
> >
> > The problem is: if I have cached query involving A class and then I
> > create/update/delete object of B class then I get invalidated query for
> > class A because both A and B class have common persistent class Base and
> > openjpa decides that changing object of class B affects cached queries
> > involving class A which is not true (I have two separate tables - one for
> A
> > and one for B class).
> >
> > This is significant problem for me because I have lots of inheritors of
> > Base class and all these inheritors have own table and don't have some
> > common table and these query cache invalidates slow system.
> >
> > Is there any workaround? I tried extending QueryCache implementations but
> > with no success (for example removing Base class from access path of
> > QueryKey object didn't help because of some other realization details of
> > QueryKey object which I can't change)
> >
>


Re: Incorrect reparameterization of a Cached prepared SQL statement with IN clause with a different number of elements

2011-05-23 Thread Michael Dick
Hi,

This is a bug, and was reported in 
https://issues.apache.org/jira/browse/OPENJPA-1845 OPENJPA-1845 . The result
of that bug report is to exclude queries that include an IN expression from
the cache with an informative message. This fix went into OpenJPA version
2.1, but not 2.0. 

Recently, an improvement JIRA has been opened to enable these queries in the
cache:  https://issues.apache.org/jira/browse/OPENJPA-2001 OPENJPA-2001 .

The SQL cache was extensively modified between OpenJPA versions 1.2 and 2.0
- which is probably why these queries worked on earlier releases. 

When I get a few cycles I'll look into porting OPENJPA-1845 back to 2.0. 

-mike


--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Incorrect-reparameterization-of-a-Cached-prepared-SQL-statement-with-IN-clause-with-a-different-numbs-tp6387137p6395804.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Problem/ understanding Optimistic Locking and Isolation Levels

2011-05-12 Thread Michael Dick
Hi Tim,

Optimistic locking is really intended to work with a 'lighter' isolation
level. The JPA spec itself assumes that you'll be using ReadCommitted.

Near the end of your email (third paragraph from the last one) you're on the
right track. Optimistic locking is intended to avoid database level locks
when using a 'lighter' isolation level (Read Committed). It does that by
throwing an exception when it detects that another transaction has modified
the data.

Optimistic Locking isn't really intended to prevent phantom reads.

That said, I wasn't aware that it would affect the TransactionIsolation
property. If you enable openjpa logging, is there anything interesting in
the output?

Here's the property to enable all logging :


Hope this helps,
-mike



On Thu, May 12, 2011 at 2:57 AM, tfriess  wrote:

> Hello,
>
> I think I have a problem understanding how the concepts of Optimistic
> Locking and Isolation Levels work together in OpenJPA.
> Maybe someone can help me understand this in detail! :)
>
> What my problem of understanding is:
> If a Transaction is in the Isolation Level "serializable", it will see the
> database in a state as it was before the Transaction was started. (And
> changes made within this transaction will be visible to other transactions
> only after a commit.)
> When I use the Optimistic Locking in OpenJPA the behaviour seems to violate
> against this assumption.
> I made two little tests to "proof" this.
> My configuration: I run this tests using OpenJPA 1.2.2 and also OpenJPA
> 2.0.1. The database is hsqldb 2.0.1.
> I activated the Optimistic Level with  value="true"/> and the isolation level with
> 
> I have caching deactivated by  value="false"/> and
> 
>
> In my first test I have one thread starting a transaction and sending a
> query "SELECT COUNT(a) FROM A a" a few times to the database,
> with some sleep time between each request (using Thread.sleep). After the
> few reads, the transaction is committed.
> Meanwhile another thread also starts a transaction, creates and persists
> such a new A and committes.
> (Right, I check for a phantom read.) What I expect is that the first
> transaction returns every time the same number for its count request, even
> if meanwhile another transaction has inserted a new record.
> But as soon as the second transaction has committed, the first transaction
> gets the new number of objects, which is a phantom read in my eyes and
> shouldn't happen
> within transactions using the isolation level "serializable".
>
> The second test works on a little parent - children relationship. I have a
> class A which has a "List children" as a field, while the Class B has a "A
> parent" field. I configured a bi-directional relationship:
> For class A (parent):
> 
> 
> 
> And in B (child):
> 
>
> Within one thread I start a transaction and fetch a concrete B entity by
> its
> unique id out of the database. Then the thread sleeps for some time and
> then calls "A theA = b.getParent()" to get a reference to A (lazy load).
> Then the transaction is commited.
> Meanwhile another thread will delete the A record from the database (note:
> the first transaction was started before A was deleted).
> In an serializable isolation level I expect that the first transaction is
> still able to read A from the database, even if meanwhile another
> transaction
> has deleted A. But A is also deleted for the first transaction, in fact I
> get a NullPointerException when the getParent() method is called.
>
>
> If I use pessimistic locking instead ( value="false"/>) it works as expected.
> (I can really see the differences between the isolation levels here. For
> example with the isolation level "read committed" it behaves as described
> above,
> which is ok for this isolation level.)
>
> So I assume I don't really get the idea behind the optimistic locking? I
> thought "optimistic locking" would only mean that transactions are not
> really blocked
> when working on data, but it could be possible that they must be rolled
> back
> when OpenJPA detects during its commit, that another transaction has also
> made changes to the same data. I have not read anywhere, that there is no
> serializable isolation level available for optimistic locking...
> Can someone please help me understanding this?
>
> Besides that I also have other question:
> What is the difference between the openjpa.Optimistic property and the
> openjpa.LockManager property? Do they depend on each other? What happens if
> I set
> openjpa.Optimistic=true and openjpa.LockManager=pessimistic? I think this
> is
> a caveat?
>
> I really would appreciate, if someone could help me.
> Thank you very much!
>
> Kind regards,
> Tim
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Problem-understanding-Optimistic-Locking-and-Isolation-Levels-tp6354862p6354862.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: SysDate-5 days implmentation

2011-05-05 Thread Michael Dick
Your query should work, assuming the value for the fivedays is of the
appropriate type (java.sql.Timestamp from what you've said).

If you could post your entities, and table definition to pastebin or
something similar that might help us. Also, which version of OpenJPA and
which database are you using?

Failing that you could use a native query and rely on the database
(presumably Oracle) to handle the sysdate keyword.

-mike

On Thu, May 5, 2011 at 5:47 PM,  wrote:

> Yes i tries ld that one. But its still diplays older than 5 days.My context
> is something different. I  don't want to use the range b/w two dates
>Here is my scenario, I want to retrieve all the the ticket bookings
> which are  starts from currentdate-5  and Bookings can be any date in
> future.
> As I said previously, in db schema the type is date but in jpa entities
> it's timestamp. Since date in SQL can store the time format like 2011-04-12
> 0:12:23 so we have kept in as date in db schema  and to store in this format
> we are using @temporal.type timestamp we r using
>
>
> > Query q = em.createQuery("Select m from Message m "
> >+ "where m.targetTime > :fivedays
>
>
> Sent from my iPhone
>
> On May 5, 2011, at 6:19 PM, Rick Curtis  wrote:
>
> > Did you try Mike's answer?
> >
> > Date now = new Date();
> > Date thirtyDaysAgo = new Date(now.getTime() - (30 * MS_IN_DAY));
> >
> > Query q = em.createQuery("Select m from Message m "
> >+ "where m.targetTime < :now and m.targetTime > :thirtyDays");
> > q.setParameter("now", now);
> > q.setParameter("thirtyDays", thirtyDaysAgo);
> >
> > List results = (List) q.getResultList();
> >
> >
> >
> > On Thu, May 5, 2011 at 4:35 PM, ram  wrote:
> >
> >> Hi,
> >>  I am trying to implement sysdate-5 in jpa.
> >>
> >> select *From emp where joinDate > sysdate-5
> >>
> >>   The problem is in db schema, join date is defined as date, but in
> >> jpa entites, we have made it as TimeStamp by using @temporal so the it
> can
> >> store exact timestamp.
> >>
> >> when i tried to query by using @namedQuery, i am getting older than
> 5
> >> days. But i need data which is just 5 days old.
> >>   I followed the following link
> >>
> >>
> http://stackoverflow.com/questions/2539035/how-to-do-a-timestamp-comparison-with-jpa-query
> >>
> >>but still i am getting same problem. Any ideas on this.
> >>
> >>
> >> Thanks
> >>
> >>
> >>
>


Re: SQL generated by TYPE() function

2011-05-05 Thread Michael Dick
Looks correct to me. There's a similar example in 
https://fisheye6.atlassian.com/browse/openjpa/tags/2.1.0/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/polymorphic/TestTablePerClassInheritanceWithAbstractRoot.java?r=1071316
this testcase  (line 203). 

-mike

--
View this message in context: 
http://openjpa.208410.n2.nabble.com/SQL-generated-by-TYPE-function-tp6310346p6334495.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Same JPQL, different results?

2011-04-29 Thread Michael Dick
I can help with the different size of the result list. 

I think you're seeing  https://issues.apache.org/jira/browse/OPENJPA-894
OPENJPA-894 . The first time the results of a FETCH JOIN query are read from
the database OpenJPA only returns the unique rows. Subsequent FETCH JOIN
queries will return duplicates (as defined by the spec). There's also 
https://issues.apache.org/jira/browse/OPENJPA-1365 OPENJPA-1365 , which
complicates things.

I think the best workaround for these issues is to make use of OpenJPA's
FetchPlans to eagerly load a relationship. 

Something like this would work :


OpenJPAEntityManager em = OpenJPAPersistence.cast(entityManager);

FetchPlan plan = em.getFetchPlan();
plan.addField(Node.class, "children");

Query query = em.createQuery("SELECT n from Node n");

I'm not sure whether this will help with your detachment problem though, but
it's worth a try.

-mike--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Same-JPQL-different-results-tp6317274p6317928.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: OpenJPA and GWT Serialization

2011-04-28 Thread Michael Dick
Hi Santa,

Currently there's no way to prevent the proxies from being created. I
started looking into making that work, but the code proved to be more
involved than I thought and I haven't gotten back to it.

Changing the schema version should cause the proxies to be removed when the
entities are serialized. There are some conditions (I think the entities
need to be detached), but for at least some use cases it should still work.

Could you check whether the entities are detached when you serialize them?

-mike


On Wed, Apr 27, 2011 at 10:21 PM, tovarisch
wrote:

> Hi Michael,
>
> I don't want to hijack your conversation, but I have the same problem, I
> have followed the tips suggested on this thread, and using schema version
> 2.0 still generates the proxies. GWT throws an exception because
> org.apache.openjpa.util.java$util$ArrayList$proxy is an unknown class for
> its serialization system.
>
> Santa.
>
>
> Jason Ferguson wrote:
> >
> > It looks like I have 1.0. I'll try switching over to 2.0 tonight and
> > let you know.
> >
> > Jason
> >
> > On Mon, Apr 11, 2011 at 9:58 AM, Michael Dick
> > <michael.d.d...@gmail.com> wrote:
> >> I took another look at the proxy code again and realized that my
> >> persistence.xml file was using version 1.0 as the schema version.
> >>
> >> Changing it to version 2.0 lead to results more like what you're looking
> >> for. Proxies still remain in the entities after the entity is detached,
> >> but
> >> will be removed when the entities are serialized.
> >>
> >> Jason, could you check what version you have specified in
> >> persistence.xml?
> >>
> >> Thanks
> >> -mike
> >>
> >>
> >>
> >> On Mon, Apr 11, 2011 at 9:22 AM, Michael Dick
> >> <michael.d.d...@gmail.com>wrote:
> >>
> >>> Hi Jason,
> >>>
> >>> Detachment and proxy classes are fairly complicated in OpenJPA. Like
> >>> Rick
> >>> mentioned I've started looking at what it'd take to remove the proxies
> >>> and
> >>> it's turned into a more sizable effort than I'd hoped.
> >>>
> >>> OpenJPA was originally designed with JEE application servers in mind
> and
> >>> it
> >>> answers that need well. Geronimo, WebSphere, and at least some versions
> >>> of
> >>> WebLogic use OpenJPA as the basis for their persistence framework.
> >>>
> >>> Outside of that area OpenJPA may require some massaging.
> >>>
> >>> There has been some work done with GWT. The OpenTrader example :
> >>> http://openjpa.apache.org/opentrader.html uses some parts of GWT, but
> >>> the
> >>> documentation is a little light in places. The source code is available
> >>> though, and may be of some help (I have no experience with GWT and
> can't
> >>> really judge).
> >>>
> >>> HTH
> >>> -mike
> >>>
> >>> On Sat, Apr 9, 2011 at 6:18 PM, Jason Ferguson
> >>> <fergusonja...@gmail.com>wrote:
> >>>
> >>>> I'm running with 2.1.0.  I figured if I was going to learn to use JPA
> >>>> versus Hibernate, I may as well use the most current version.
> >>>>
> >>>> So let me see if I'm doing this right. I added the following property
> >>>> to persistence.xml:
> >>>>
> >>>>  >>>> value="loaded(LiteAutoDetach=true)"
> >>>> />
> >>>>
> >>>> The docs seem to recommend adding a version field, which I haven't
> >>>> done yet. I also choose "loaded" versus "fetch-group" because I hadn't
> >>>> defined any custom fetch groups.
> >>>>
> >>>> With no offense intended towards the developers, I'm getting the
> >>>> impression that OpenJPA is currently not the right choice for a GWT
> >>>> project, until this particular issue is resolved.
> >>>>
> >>>> Jason
> >>>>
> >>>>
> >>>> On Sat, Apr 9, 2011 at 7:43 AM, Rick Curtis <curti...@gmail.com
> >
> >>>> wrote:
> >>>> > Jason -
> >>>> >
> >>>> >> Sorry if this is a frequently asked question.
> >>>> > This isn't a frequent question... yet. It seems that this issue has
> >>>>

Re: OpenJPA 2.1.0 regression: PostgreSQL ClassCastException?

2011-04-26 Thread Michael Dick
The root cause here is that the table was generated with OpenJPA 2.0.1,
which used ABSTIME instead of TIMESTAMP as the column type. The default type
was changed in OPENJPA-1726, and the code that uses the default TS type was
not properly updated. I've updated OPENJPA-1985 with the same info.

A quick workaround is to add this property to persistence.xml



Thanks for reporting the problem and opening a JIRA.

-mike

On Mon, Apr 25, 2011 at 8:24 AM, Stanislav Mironov wrote:

> Hi everyone!
>
> After OpenJPA 2.0.1 -> 2.1.0 upgrade I've got this on PostgreSQL 9.0.4
> (x64) with PostgreSQL JDBC driver 9.0-801 (latest stable versions):
>
> 250  pf  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.PostgresDictionary" (PostgreSQL 9.0.4
> ,PostgreSQL Native Driver PostgreSQL 9.0 JDBC4 (build 801)).
> 455  pf  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.1.0
> SEVERE: Failed to execute query "select max(h.loadTimestamp) from
> Header h where h.code=?1 and h.period=?2". Check the query syntax for
> correctness. See nested exception for details.
> 
> org.apache.openjpa.persistence.ArgumentException: Failed to execute
> query "select max(h.loadTimestamp) from Header h where h.code=?1 and
> h.period=?2". Check the query syntax for correctness. See nested
> exception for details.
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872)
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
>at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:305)
>at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:319)
>at
> org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:343)
>... my code ...
>at java.lang.Thread.run(Thread.java:662)
> Caused by: java.lang.ClassCastException: Cannot convert object
> "2011-04-25 15:48:31+02" of type "class org.postgresql.util.PGobject"
> into an instance of "class java.sql.Timestamp".
>at org.apache.openjpa.kernel.Filters.convert(Filters.java:336)
>at org.apache.openjpa.kernel.Filters.convert(Filters.java:265)
>at
> org.apache.openjpa.jdbc.kernel.exps.UnaryOp.load(UnaryOp.java:125)
>at
> org.apache.openjpa.jdbc.kernel.ProjectionResultObjectProvider.getResultObject(ProjectionResultObjectProvider.java:78)
>at
> org.apache.openjpa.kernel.QueryImpl$PackingResultObjectProvider.getResultObject(QueryImpl.java:2075)
>at
> org.apache.openjpa.kernel.QueryImpl.singleResult(QueryImpl.java:1330)
>at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1242)
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
>... 12 more
>
> Here is the entity:
>
> @Entity
> @Table(name = "headers")
> @DataCache(enabled = false)
> public class Header {
>@Id
>@GeneratedValue
>private long id;
>
>@Column(nullable = false)
>private String code;
>
>@Column(nullable = false)
>private int period;
>
>@Column(nullable = false)
>@Temporal(TemporalType.TIMESTAMP)
>private Timestamp loadTimestamp;
> ...
> }
>
> Configuration:
>
>
>  
> 
>
>pkg.Header
>
>
>
>
> value="EvictFromDataCache=true"/>
> value="true(CacheSize=1, SoftReferenceSize=10)"/>
>
> value="buildSchema"/>
>  value="ForeignKeyDeleteAction=restrict,
> JoinForeignKeyDeleteAction=restrict"/>
>
>
>
>
>
> Database schema built automatically with OpenJPA 2.0.1.
>
> Works perfectly in OpenJPA 2.0.1. Regression?
>
> --
> Stanislav Mironov
>


Re: Could not map discriminator value to any known subclasses

2011-04-21 Thread Michael Dick
Hi Phill,

The snippets from your entities are correct. Which version of OpenJPA are
you using, and how do you do enhancement?

Could the app be picking up an old version of Merchant that doesn't have the
annotation, or an XML mapping file that reset it to a different value?

-mike

On Wed, Apr 20, 2011 at 9:39 AM, Phill  wrote:

> I'm having some trouble with joined inheritance, my mappings are as follows
> but OpenJPA doesn't seem to be picking up my @DiscriminatorValue.
> Probably missing something obvious but can't see what... any suggestions
> much appreciated
>
> @Entity
> @Table(name = "user_account")
> @Inheritance(strategy = InheritanceType.JOINED)
> @DiscriminatorColumn(name = "account_type", discriminatorType =
> DiscriminatorType.STRING)
> public abstract class UserAccount implements Serializable {
> ...
>
> @Entity
> @Table(name = "merchant")
> @DiscriminatorValue("MERCHANT")
> @PrimaryKeyJoinColumn(name = "merchant_id", referencedColumnName =
> "account_id")
> public class Merchant extends UserAccount {
> ...
>
> java.lang.ClassNotFoundException: Could not map discriminator value
> "MERCHANT" to any known subclasses of the requested class
> "my.app.model.UserAccount" (known discriminator values: [UserAccount]).
> at
> org.apache.openjpa.jdbc.meta.strats.ValueMapDiscriminatorStrategy.getClass(ValueMapDiscriminatorStrategy.java:98)
> at
> org.apache.openjpa.jdbc.meta.strats.InValueDiscriminatorStrategy.getClass(InValueDiscriminatorStrategy.java:121)
> at
> org.apache.openjpa.jdbc.meta.Discriminator.getClass(Discriminator.java:398)
> at
> org.apache.openjpa.jdbc.meta.strats.SuperclassDiscriminatorStrategy.getClass(SuperclassDiscriminatorStrategy.java:63)
> at
> org.apache.openjpa.jdbc.meta.Discriminator.getClass(Discriminator.java:398)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:397)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
> at
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
> at
> org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:360)
> at
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
> at
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> at
> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1022)
> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:980)
> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:902)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1041)
> at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
> at
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
> at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
> at
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
> at
> org.apache.openjpa.lib.rop.EagerResultList.(EagerResultList.java:36)
> at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1251)
> at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
> at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
> at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
> at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
> at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:305)
> at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:319)


Re: Changes during a Listener

2011-04-21 Thread Michael Dick
This is a bit of a gray area.. The spec (section 3.5) says :
• In general, the lifecycle method of a portable application should not
invoke EntityManager
or Query operations, access other entity instances, or modify relationships
within the
same persistence context.[43] A lifecycle callback method may modify the
non-relationship
state of the entity on which it is invoked.

[43] The semantics of such operations may be standardized in a future
release of this specification.

Your application might not be directly calling EntityManager.merge() or
.persist(), but you are adding a new relationship (if I follow your example
correctly) and the operation is cascaded.

The OpenJPA manual provides slightly different wording :

   -


PreUpdate:
   Methods marked with this annotation will be invoked just the persistent
   values in your objects are flushed to the datastore. This is equivalent to
   the XML element tagpre-update.

   PreUpdate is the complement to PostLoad . While methods marked with
   PostLoad are most often used to initialize non-persistent values from
   persistent data, methods annotated with PreUpdate is normally used to set
   persistent fields with information cached in non-persistent data.
   -


PostUpdate:
   Methods marked with this annotation will be invoked after changes to a given
   instance have been stored to the datastore. This is useful for clearing
   stale data cached at the application layer. This is equivalent to the XML
   element tag post-update.

In short, if this is going to work you should use the PreUpdate callback
instead of PostUpdate.  PostUpdate happens after we've written to the
database. I'm not sure why PostUpdate works with managed transactions
(Spring), but it's probably a happy coincidence.

Note that what you're trying to do is not covered by the JPA spec, and the
OpenJPA docs don't explicitly indicate that this _will_ work, but moving to
the PreUpdate callback should be the first step.

Hope this helps
-mike

On Thu, Apr 21, 2011 at 8:17 AM, Jim Talbut  wrote:

> Hi,
>
> Under what circumstances can a PostUpdate listener create new entities?
>
> I have a set of entities with PostUpdate listeners that create additional
> records to track changes.
> In some of my tests this is working correctly (with the transaction managed
> by a Spring @Transaction on a Struts action) but in others (stripped back to
> handle the transaction manually) the main entity is created but the related
> (change tracking) entity is not.
>
> Both cases are using the same code for creating the change tracking entity
> is identical, and neither explicitly accesses the entity manager to persist
> it (relying on cascading).
>
> Thanks.
>
> Jim
>


Re: Can't get hellopjpa from examples working.

2011-04-21 Thread Michael Dick
Hi again,

I'm glad you're making progress, but I'm stumped as to why you're seeing
version 2.1.0 in the error. I was expecting to see something obvious on the
classpath but if it's there I've missed it.

Maybe someone on the list who also has a mac can chime in?
-mike

On Thu, Apr 21, 2011 at 2:52 AM, Joep Simons  wrote:

> Hi,
>
> I got the following output:
>
> On another note: The exception disappeared in my 'test-code' when I added a
> second @entity object with a relation to the first. Not sure if that means
> something, but at least I can continue.
>
> buildfile:
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/build.xml
>
> pre-compile:
>
> compile:
>[javac]
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/build.xml:104:
> warning: 'includeantruntime' was not set, defaulting to
> build.sysclasspath=last; set to false for repeatable builds
>
> run:
>  [echo]  =
> [echo]  javaagent:
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/openjpa-2.2.0-20110415.075847-49.jar
> [echo]  parent   :
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/..
> [echo]  root :
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/../../..
> [echo]  myCp :
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple:/Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/lib/derby-10.5.3.0_1.jar:/Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/openjpa-all-2.2.0-SNAPSHOT.jar
> [echo]  =
>  [java] Exception in thread "main"  nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException:
> Already closed.
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:558)
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Can-t-get-hellopjpa-from-examples-working-tp6262603p6293513.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Can't get hellopjpa from examples working.

2011-04-19 Thread Michael Dick
Hi Joep,

Can you modify the build.xml file in the simple directory with this (it
should go right after the tag for . It's line 113 in
my copy.


 = 
 javaagent: ${javaagent} 
 parent   : ${parent} 
 root : ${root} 
 myCp : ${myClasspath} 
 = 

The output should look something like this
run:
 [echo]
 ===
 [echo]  javaagent:
/home/mikedd/apache-openjpa-2.2.0-SNAPSHOT/openjpa-2.2.0-SNAPSHOT.jar
 [echo]  parent   :
/home/mikedd/apache-openjpa-2.2.0-SNAPSHOT/examples/simple
 [echo]  root : /home/mikedd/apache-openjpa-2.2.0-SNAPSHOT
 [echo]  myCp :
/home/mikedd/apache-openjpa-2.2.0-SNAPSHOT/examples/simple:/home/mikedd/apache-openjpa-2.2.0-SNAPSHOT/lib/derby-10.5.3.0_1.jar:/home/mikedd/apache-openjpa-2.2.0-SNAPSHOT/openjpa-all-2.2.0-SNAPSHOT.jar
 [echo]
 ===

It looks like you're loading a different version. Running ant -v might also
help but there'll be a lot of data to parse through.

-mike

On Mon, Apr 18, 2011 at 1:42 PM, Joep Simons  wrote:

> hi,
>
> I tried it and it still gives the same error. What I find strange is that
> the 'relations' demo does work, although it looks quite the same as the
> hellojpa demo. Another thing is that it gives the build from the 2.1
> version
> in the exception description.
>
> best regards,
>
>   Joep
>
> ant
> Buildfile:
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/build.xml
>
> pre-compile:
>
> compile:
>[javac]
>
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/build.xml:104:
> warning: 'includeantruntime' was not set, defaulting to
> build.sysclasspath=last; set to false for repeatable builds
>
> run:
>  [java] Exception in thread "main"  nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException:
> Already closed.
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:558)
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:456)
> [java] at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:160)
> [java] at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:164)
> [java] at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:122)
> [java] at
>
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:210)
> [java] at
>
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
> [java] at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
> [java] at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
> [java] at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
> [java] at hellojpa.Main.main(Main.java:43)
> [java] Caused by: java.sql.SQLException: Already closed.
> [java] at
>
> org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
> [java] at
>
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
> [java] at
>
> org.apache.openjpa.lib.jdbc.DelegatingConnection.close(DelegatingConnection.java:205)
> [java] at
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.close(LoggingConnectionDecorator.java:431)
> [java] at
>
> org.apache.openjpa.lib.jdbc.DelegatingConnection.close(DelegatingConnection.java:205)
> [java] at
>
> org.apache.openjpa.jdbc.schema.SchemaGenerator.closeConn(SchemaGenerator.java:1072)
> [java] at
>
> org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:327)
> [java] at
>
> org.apache.openjpa.jdbc.schema.SchemaTool.getDBSchemaGroup(SchemaTool.java:1163)
> [java] at
> org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:363)
> [java] at
> org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:340)
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:505)
> [java] ... 10 more
>
> BUILD FAILED
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Can-t-get-hellopjpa-from-examples-working-tp6262603p6284708.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Can't get hellopjpa from examples working.

2011-04-15 Thread Michael Dick
Bad choice of words and a rushed email on my part.

I was thinking of the pre-compiled binaries from the snapshot
repository.
The link is near the middle of the downloads
page,
and I forgot to include it.

I'm not sure what to make of the IllegalAccessError though. Sorry for
unintentionally sending you down a rathole - can you try with the link
above?

-mike

On Fri, Apr 15, 2011 at 3:09 PM, Joep Simons  wrote:

> Hi,
>
> It was the first time that I used maven, so I am not sure if I did
> everything ok. When I checked out and tries to build the openjpa I got an
> error that some of the tests were failing. Because this might be caused by
> my ignorance, I'll post a abbreviated log here. The error is at the end.
> Sorry that I cannot be of more help
>
> regards,
>   Joep
>
>
> d:openjpa simons$ svn checkout
> http://svn.apache.org/repos/asf/openjpa/trunk
> openjpa
> Aopenjpa/NOTICE
> A
>
> openjpa/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/LockTimeoutException.java
> A
>
> openjpa/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/validation/localizer.properties
> Aopenjpa/openjpa-persistence/pom.xml
>  U   openjpa
> Checked out revision 1092489.
> o:openjpa simons$ ls
> openjpa
> o:openjpa simons$ cd openjpa/
>
> ……..
>
>
> o:openjpa simons$ cd openjpa/
> o:openjpa simons$ ls
> LICENSE openjpa-persistence
> NOTICE  openjpa-persistence-jdbc
> README.txt  openjpa-persistence-locking
> openjpa openjpa-project
> openjpa-all openjpa-slice
> openjpa-examplesopenjpa-tools
> openjpa-integration openjpa-xmlstore
> openjpa-jdbcpom.xml
> openjpa-jestscripts
> openjpa-kernel  src
> openjpa-lib
> o:openjpa simons$ svn update
> At revision 1092787.
> o:openjpa simons$ mvn
> [INFO] Scanning for projects...
> Downloading:
> http://repo1.maven.org/maven2/org/apache/apache/7/apache-7.pom
> Downloaded: http://repo1.maven.org/maven2/org/apache/apache/7/apache-7.pom
> -testing-harness-1.0-beta-1.jar (18 KB at 8.1 KB/sec)
> [INFO] Exclude: **/.*/**
> [INFO] Exclude: **/target/**/*
> [INFO]
> [INFO] --- maven-install-plugin:2.3:install (default-install) @
> openjpa-parent ---
> Downloading:
>
> http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.pom
> Downloaded:
>
> http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.pom
> (2 KB at 1.1 KB/sec)
> Downloading:
>
> http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.jar
> Downloaded:
>
> http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.jar
> (12 KB at 25.3 KB/sec)
> [INFO] Installing /Users/simons/openjpa/openjpa/pom.xml to
>
> /Users/simons/.m2/repository/org/apache/openjpa/openjpa-parent/2.2.0-SNAPSHOT/openjpa-parent-2.2.0-SNAPSHOT.pom
> [INFO]
> [INFO]
> 
> [INFO] Building OpenJPA Utilities Library 2.2.0-SNAPSHOT
> [INFO]
> 
> Downloading:
>
> http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.3.1/maven-jar-plugin-2.3.1.pom
> Downloaded:
>
> http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.3.1/maven-jar-plugin-2.3.1.pom
> (6 KB at 6.6 KB/sec)
> Downloading:
>
> http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom
> Downloaded:
>
> http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom
> (13 KB at 15.6 KB/sec)
> Downloading:
>
> http://repo1.maven.org/maven2/org/apache/maven/maven-parent/16/maven-parent-16.pom
>
> …..
> Downloaded:
> http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar
> (25 KB at 5.4 KB/sec)
> Downloaded:
>
> http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
> (562 KB at 102.4 KB/sec)
> [INFO]
> [INFO] --- buildnumber-maven-plugin:1.0-beta-4:create (default) @
> openjpa-lib ---
> [INFO]
> [INFO] --- maven-enforcer-plugin:1.0-beta-1:enforce (default) @ openjpa-lib
> ---
> [INFO]
> [INFO] --- maven-checkstyle-plugin:2.2:checkstyle (default) @ openjpa-lib
> ---
> [INFO] Starting audit...
> Audit done.
>
> [WARNING] Unable to locate Source XRef to link to - DISABLED
> [INFO]
> [INFO] --- maven-remote-resources-plugin:1.1:process (default) @
> openjpa-lib
> ---
> [INFO]
> [INFO] --- maven-resources-plugin:2.4:resources (default-resources) @
> openjpa-lib ---
> Downloading:
>
> http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.5.15/plexus-

Re: @Version for sqlserver "timpstamp" datatype

2011-04-15 Thread Michael Dick
Hi Chintan,

Serializable will obtain more locks than Repeatable Read. You probably want
to use Read Committed as the default isolation level. Read Committed is the
default level per the JPA specification.

If you'd like more information there are a lot of good primers on isolation
levels on the Internet, here's one from the derby
documentation
.

hope this helps
-mike

On Fri, Apr 15, 2011 at 10:56 AM, chintan4181  wrote:

> Hi Mike,
>
> Currenty Isolation level in Websphere is 4- Repetable Read. Tried with
> Serializable (8), but it did not work.
>
> I am trying to simulate the scenario using SOAP UI tool. Multiple threads
> are starting parrellaly to update same record. So here i found two
> behaviours
> If i dont use em.lock(entity, LOCKModeType.OTIMISTIC) (which is deafult),
> all threads are updating reocords. No exception is thrown.
>
> If i use em.lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT), i am
> getting lock time out error.
>
> which level of isolation will help me to solve this issue?
>
> Thanks
> Chintan
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6276784.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: @Version for sqlserver "timpstamp" datatype

2011-04-15 Thread Michael Dick
Hi Chintan,

Implicit locking is not the same as optimistic locking.

By implicit locking I meant the database locks which are obtained
automatically when you obtain a connection. This level of locking depends on
the isolation level in use. I probably should have referred to it as
isolation level locking to avoid confusion.

I'm doing a little guessing here, I don't know that the isolation level is
the cause of the lock timeout, it just looks likely since there's no sign of
OpenJPA locking the table (the UPDLOCK statement).

Hope this helps,
-mike

On Thu, Apr 14, 2011 at 5:56 PM, chintan4181  wrote:

> Hi Mike,
>
> Implicit locking is same as Optimistic locking?
>
> ~chintan
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6274638.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: @Version for sqlserver "timpstamp" datatype

2011-04-15 Thread Michael Dick
Hi Chintan,

This issue might be best handled through the WebSphere support channels.

I'm assuming you changed the
openjpa.jdbc.TransactionIsolation
 persistence property. This has the effect of changing the isolation level
after a connection is obtained from WebSphere's connection pool. Subsequent
requests for a connection will get a new connection from the pool and
promptly change the isolation level. As a result you end up with multiple
connections associated with the same tran, and the transaction needs to be
upgraded to XA.

What you probably want to do is change the default isolation level on the
WebSphere DataSource. The best way to do this is to use a resource reference
in your application, and set the isolation on the resource ref. There is
also a custom property that you can set on the DataSource documented
here
(scroll
down a little bit to see the custom property).

If you read the link about the custom property you'll see there are a few
more options, but the resource ref and custom property are the two that I've
seen work in the past.

Hope this helps,
-mike

On Thu, Apr 14, 2011 at 3:54 PM, chintan4181  wrote:

> Hi Mike,
>
> enabled loggin and searched for "WITH (UPDLOCK) but i could not find any
> such entry. How can i remove implicit locking by changing isoloation level.
> I tried adding
>
>  In this case i am getting below exception.
>
>  org.apache.openjpa.lib.jdbc.ReportingSQLException: enlist: caught
> Exception
> com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException: Illegal
> attempt to enlist multiple 1PC XAResources
>
> can you please help me to resolve error?
>
> thanks
> chintan
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6274371.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: @Version for sqlserver "timpstamp" datatype

2011-04-14 Thread Michael Dick
In WebSphere you can just enable the trace group "openjpa=all" and OpenJPA
trace will go to the normal WebSphere trace file. 

The trace groups you want are openjpa.jdbc.SQL=all:openjpa.jdbc.JDBC=all.
Here's more on how to enable the trace in WebSphere : 
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp 



--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6274108.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: @Version for sqlserver "timpstamp" datatype

2011-04-14 Thread Michael Dick
Hi Chintan,

We're getting a LockTimeoutException from SQLServer, which is why you're
seeing a different exception.

OpenJPA handles locking on SQLServer a little differently from other
databases. Instead of a FOR UPDATE clause we obtain a table lock.

It would be most helpful if you could enable logging for SQL and JDBC :


In the trace file look for an instance of "WITH (UPDLOCK)" . If that's
present, OpenJPA has locked the table (e.g. pessimistic locking). If it
isn't found in the trace then it may be a case of implicit locking due to
your isolation level.

Providing your persistence.xml (pastebin if possible) may be a big help in
either case.

-mike

On Thu, Apr 14, 2011 at 12:06 PM, chintan4181  wrote:

> Few more details: Loan object has one-to-one relation with other object and
> i
> have already queried parent object which contains loan object.
>
> so Parent p = em.find(Parent.class, pId);
> Loan loan = p.getLoan();
>
> //setting loan values
>
> //lock loan object with optimistic lock
> //persist it.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6273590.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Can't get hellopjpa from examples working.

2011-04-14 Thread Michael Dick
Hi Joep,

I think there's a problem obtaining a connection - maybe a security setting
that's different for macs? I don't have access to one to try, and
unfortunately the exception closing a connection appears to be hiding the
root cause.

I'll fix the problem with closing a connection and that will get picked up
in the next nightly snapshot. Can you try again with a trunk build?

-mike

On Tue, Apr 12, 2011 at 10:20 AM, Joep Simons  wrote:

> Hi Mike,
>
> Thank you for your reply. I just downloaded and checked it on another apple
> and it gave the same result. However, when I tried to run it on a linux
> machine, it worked out of the box.
>
> I am not sure if anyone can reproduce my problem on Mac osX. Maybe I should
> file a bug report. But at least I can reasonably suspect that it is related
> to the java implementation on osx.
>
> regards,
>   Joep
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Can-t-get-hellopjpa-from-examples-working-tp6262603p6265558.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: @Version for sqlserver "timpstamp" datatype

2011-04-14 Thread Michael Dick
Hi Chintan,

I'm not very familiar with SQLServer, and I can't recommend a JDBC driver.
It's possible that DataDirect or Microsoft have other workarounds that will
convert a timestamp to another Java type, but it's probably unlikely.

If you cannot introduce a new column it's very hard to do optimistic
locking.

I'm sorry I don't have a good solution for this problem. Maybe someone else
on the list will have a better idea.

-mike

On Wed, Apr 13, 2011 at 10:01 AM, chintan4181  wrote:

> Thanks Mike. are you aware of any mssql jdbc driver which maps timestamp to
> java.sql.TimeStamp? becuase i can not introduce new version column in
> existing db.
>
> can youplease guide me any other way to implement optimistic locking?
>
> ~chintan
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6269353.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: two issues when not using a DetachedStateField

2011-04-13 Thread Michael Dick
Hi,

I did a quick search through the open issues and there are several reported
problems with cascading. I don't know which one fits your scenario the best.
It would help me (at least) if I could see the test case you mentioned.

I'd recommend either opening a new JIRA and attaching your testcase to it,
or posting the testcase to something like pastebin .

 -mike

On Wed, Apr 13, 2011 at 7:59 AM, Henno Vermeulen wrote:

> Even though the merge succeeds, there is one big issue with removing the
> cascade from the bidirectional relation namely I get that
>
> event != event.activities.get(0).event
>
> Could this mean that event is unnecessarily fetched and extra unnecessary
> SQL gets executed (I've seen issues on this)?
>
> -Oorspronkelijk bericht-
> Van: Henno Vermeulen [mailto:he...@huizemolenaar.nl]
> Verzonden: woensdag 13 april 2011 14:40
> Aan: 'users@openjpa.apache.org'
> Onderwerp: RE: two issues when not using a DetachedStateField
>
> Issue 2 also does not occury when Activity to Event is not set to cascade.
> The issue also doesn't occur when StringI18N is removed and the object
> graph is only three entities deep. So it is quite a complicated combination
> of factors: no detached state field, four entities and a cascade from
> Activity to Event...
>
> -Oorspronkelijk bericht-
> Van: Henno Vermeulen [mailto:he...@huizemolenaar.nl]
> Verzonden: woensdag 13 april 2011 14:30
> Aan: 'users@openjpa.apache.org'
> Onderwerp: two issues when not using a DetachedStateField
>
> We use OpenJPA 2.1.0 with build time enhancement. We have a client/server
> situation so we always detach + serialize entities on commit using fetch
> groups:
>
>  value="fetch-groups(DetachedStateField=false)" />
>
> We currently don't use a DetachedStateField or DetachedStateManager because
> everything worked fine without them until now.
>
> I found two issues that don't occur when I use DetachedStateField=true.
> (According to the user guide OpenJPA should function just as well without
> one except that it may be less efficient. "OpenJPA can take advantage of a
> detached state field to make the attach process more efficient. This field
> is added by the enhancer and is not visible to your application.")
>
>
> Issue 1:
> When I add a new entity to a List of a detached (but not Serialized) entity
> and then merge, OpenJPA throws:
>
> org.apache.openjpa.persistence.InvalidStateException: The context has been
> closed.  The stack trace at which the context was closed is held in the
> embedded exception.
> FailedObject: java.lang.IllegalStateException
>at
> org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4615)
> ...
>
> We don't experience this as a problem because we always Serialize an entity
> before adjusting it!!!
>
>
> Issue 2:
> We have an object graph of four entities with autogenerated Id columns:
>
> Event (OneToMany bidirectional) Activity (OneToMany) ProductOrderLine
> (OneToOne) StringI18N
>
> All relations are FetchType.EAGER and Cascade.ALL.
>
> When I add a new Activity (with one new ProductOrderLine with one new
> StringI18N) to an existing Event and then merge the Event, OpenJPA tries to
> insert a null value into the StringI18N Id column. This seems to be only
> detected on transaction commit.
>
> This problem does not occur when:
>
> -  I make the Event - Activity relation unidirectional, i.e.
> Activity does not know it's parent Event.
>
> -  The Event is new as well.
>
> -  (workaround) I first add the new Activity to the Event but with
> no ProductOrderLines, then merge the Event, then add the ProductOrderLine to
> the Activity in the and merge the Event again.
>
> Are these known issues? What is the best way for me to go? Should I do my
> workaround or should I try to use a detached state field?
> Shall I report this to JIRA? I have a test case which shows these issues.
>
>
> Regards,
>
> Henno Vermeulen
> Huize Molenaar
>
>


Re: @Version for sqlserver "timpstamp" datatype

2011-04-12 Thread Michael Dick
Hi Chintan,

Version fields may be of the following types:
int, Integer, short, Short, long, Long, java.sql.Timestamp.

Based on your previous email the MSSQL timestamp should be mapped to a
byte[] which won't work as a version column. If the JDBC driver can map a
timestamp to one of the types listed above it should work. If not I'm afraid
the answer is no. At least for now.

-mike

On Tue, Apr 12, 2011 at 7:20 PM, chintan4181  wrote:

> Hi,
>
> In my sql server 2005 database schema, all tables have one column with
> "timestamp" dataType. When I generate entity out of it, Java maps that
> column with java.sql.TimeStamp dataType. but when I retrieve entity using
> JPA, i am getting below error.
>
> 2 PDT] 0044 SystemErr R Caused by:
> com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from
> timestamp to TIMESTAMP is unsupported.
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:1117)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
> com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:2419)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
> com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:176)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
> com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:113)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1981)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1966)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> com.microsoft.sqlserver.jdbc.SQLServerResultSet.getTimestamp(SQLServerResultSet.java:2367)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getTimestamp(WSJdbcResultSet.java:2613)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.lib.jdbc.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:189)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.sql.DBDictionary.getTimestamp(DBDictionary.java:871)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.sql.ResultSetResult.getTimestampInternal(ResultSetResult.java:485)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.sql.ResultSetResult.getObjectInternal(ResultSetResult.java:439)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.sql.AbstractResult.getObject(AbstractResult.java:691)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy.populateFromResult(ColumnVersionStrategy.java:336)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy.load(ColumnVersionStrategy.java:269)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
> org.apache.openjpa.jdbc.meta.Version.load(Version.java:343)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1103)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1076)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:447)
> [4/12/11 16:16:59:642 PDT] 0044 SystemErr R at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:342)
>
> I am using Microsoft SQL Server JDBC Driver 3.0. and driver documentation
> says that
> Note:
> The SQL Server timestamp type is a fixed-length binary-string type. It does
> not map to any of the JDBC time types: DATE, TIME, or TIMESTAMP.
>
> And I want to make "timestamp" column as a @version column to implement
> Optimistic locking. since it is existing database i can not add new column
> with int dataType for versioning.
>
> Is there a way to use sql server "timestamp" type as @version column in
> JPA/OpenJPA?
>
> Thanks
> Chintan
>
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6267241.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: OpenJPA 2.0 and Glassfish 3.1 issue

2011-04-11 Thread Michael Dick
Hi,

I think you're hitting
OPENJPA-1410.
There's a lot of comments to read through, but I think it boils down to
adding these two
propertiesto
persistence.xml :




At a high level the problem appears to be with the classloader hierarchy in
Glassfish.

Hope this helps,
-mike

On Mon, Apr 11, 2011 at 2:38 PM, chuongpham  wrote:

> I get an error when running OpenJPA 2.0 within Glassfish 3.1 server. The
> full
> stacktrace of the error is:
>
> WARNING: A system exception occurred during an invocation on EJB
> BookService
> method public com.ckd.model.BookModel
>
> com.ckd.business.BookService.find(java.lang.Long)
> javax.ejb.EJBException
>at
>
> com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5194)
>at
> com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5092)
>at
> com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4880)
>at
> com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
>at
> com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
>at
>
> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
>at
>
>
> com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
>at $Proxy156.find(Unknown Source)
>at
>
> com.ckd.business.__EJB31_Generated__BookService__IntfBean__.find(Unknown
> Source)
>at com.ckd.presentation.BookBean.init(BookBean.java:64)
>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.glassfish.faces.integration.GlassFishInjectionProvider$2.run(GlassFishInjectionProvider.java:386)
>at java.security.AccessController.doPrivileged(Native Method)
>at
>
>
> org.glassfish.faces.integration.GlassFishInjectionProvider.invokeLifecycleMethod(GlassFishInjectionProvider.java:380)
>at
>
> org.glassfish.faces.integration.GlassFishInjectionProvider.invokePostConstruct(GlassFishInjectionProvider.java:310)
>at
>
> org.glassfish.faces.integration.GlassFishInjectionProvider.invokePostConstruct(GlassFishInjectionProvider.java:233)
>at
> com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:223)
>at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
>at
> com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
>at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
>at
>
> com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
>at
>
> com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
>at
>
> com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
>at
>
> com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
>at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:99)
>at com.sun.el.parser.AstValue.getValue(AstValue.java:158)
>at com.sun.el.parser.AstEmpty.getValue(AstEmpty.java:62)
>at com.sun.el.parser.AstNot.getValue(AstNot.java:59)
>at
> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
>at
> org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55)
>at
>
> com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
>at
>
> javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
>at
> javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:413)
>at
>
> com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:117)
>at
>
> javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
>at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
>at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
>at
>
> javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
>at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
>at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
>at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
>at
>
> com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
>at
>
> com.sun.faces.applic

Re: Can't get hellopjpa from examples working.

2011-04-11 Thread Michael Dick
Hi Joep,

You're posting to the right forum. The stack indicates that there's a
problem with a connection. Have you changed anything in the sample related
to the database?

I just downloaded a fresh copy and I wasn't able to reproduce the problem
(Oracle Java 1.6.0_24 on Linux).

-mike

On Mon, Apr 11, 2011 at 2:20 PM, Joep Simons  wrote:

> Hello,
>
> I downloaded apache-openjpa-2.1.0 in order to try it out, starting with a
> simple example. Unfortunately I cannot get the simple hellojpa example from
> the examples working. I use apple snow-leopard (java 1.6.0_24)
>
>
> I am not sure if I am posting in the right forum since I am totally new to
> openjpa. On the other hand, I get the same error when trying my own 'demo'
> project, so I am quite stuck right now.
>
> Thanks in advance
>
> best regards,
> Joep
>
> hellojpa simons$ ant
> Buildfile:
>
> /Users/simons/Downloads/apache-openjpa-2.1.0/examples/simple/hellojpa/build.xml
>
> pre-compile:
>
> compile:
>[javac]
> /Users/simons/Downloads/apache-openjpa-2.1.0/examples/simple/build.xml:104:
> warning: 'includeantruntime' was not set, defaulting to
> build.sysclasspath=last; set to false for repeatable builds
>
> run:
> [java] Exception in thread "main"
> org.apache.openjpa.persistence.PersistenceException: Already closed.
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:558)
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:456)
> [java] at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:160)
> [java] at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:164)
> [java] at
>
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:122)
> [java] at
>
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:210)
> [java] at
>
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
> [java] at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
> [java] at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
> [java] at
>
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
> [java] at hellojpa.Main.main(Main.java:43)
> [java] Caused by: java.sql.SQLException: Already closed.
> [java] at
>
> org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
> [java] at
>
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
> [java] at
>
> org.apache.openjpa.lib.jdbc.DelegatingConnection.close(DelegatingConnection.java:205)
> [java] at
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.close(LoggingConnectionDecorator.java:431)
> [java] at
>
> org.apache.openjpa.lib.jdbc.DelegatingConnection.close(DelegatingConnection.java:205)
> [java] at
>
> org.apache.openjpa.jdbc.schema.SchemaGenerator.closeConn(SchemaGenerator.java:1072)
> [java] at
>
> org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:327)
> [java] at
>
> org.apache.openjpa.jdbc.schema.SchemaTool.getDBSchemaGroup(SchemaTool.java:1163)
> [java] at
> org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:363)
> [java] at
> org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:340)
> [java] at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:505)
> [java] ... 10 more
>
> BUILD FAILED
> /Users/simons/Downloads/apache-openjpa-2.1.0/examples/simple/build.xml:115:
> Java returned: 1
>
> Total time: 5 seconds
> :hellojpa simons$
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Can-t-get-hellopjpa-from-examples-working-tp6262603p6262603.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: OpenJPA and GWT Serialization

2011-04-11 Thread Michael Dick
I took another look at the proxy code again and realized that my
persistence.xml file was using version 1.0 as the schema version.

Changing it to version 2.0 lead to results more like what you're looking
for. Proxies still remain in the entities after the entity is detached, but
will be removed when the entities are serialized.

Jason, could you check what version you have specified in persistence.xml?

Thanks
-mike



On Mon, Apr 11, 2011 at 9:22 AM, Michael Dick wrote:

> Hi Jason,
>
> Detachment and proxy classes are fairly complicated in OpenJPA. Like Rick
> mentioned I've started looking at what it'd take to remove the proxies and
> it's turned into a more sizable effort than I'd hoped.
>
> OpenJPA was originally designed with JEE application servers in mind and it
> answers that need well. Geronimo, WebSphere, and at least some versions of
> WebLogic use OpenJPA as the basis for their persistence framework.
>
> Outside of that area OpenJPA may require some massaging.
>
> There has been some work done with GWT. The OpenTrader example :
> http://openjpa.apache.org/opentrader.html uses some parts of GWT, but the
> documentation is a little light in places. The source code is available
> though, and may be of some help (I have no experience with GWT and can't
> really judge).
>
> HTH
> -mike
>
> On Sat, Apr 9, 2011 at 6:18 PM, Jason Ferguson wrote:
>
>> I'm running with 2.1.0.  I figured if I was going to learn to use JPA
>> versus Hibernate, I may as well use the most current version.
>>
>> So let me see if I'm doing this right. I added the following property
>> to persistence.xml:
>>
>> > />
>>
>> The docs seem to recommend adding a version field, which I haven't
>> done yet. I also choose "loaded" versus "fetch-group" because I hadn't
>> defined any custom fetch groups.
>>
>> With no offense intended towards the developers, I'm getting the
>> impression that OpenJPA is currently not the right choice for a GWT
>> project, until this particular issue is resolved.
>>
>> Jason
>>
>>
>> On Sat, Apr 9, 2011 at 7:43 AM, Rick Curtis  wrote:
>> > Jason -
>> >
>> >> Sorry if this is a frequently asked question.
>> > This isn't a frequent question... yet. It seems that this issue has come
>> up
>> > a number of times on users/dev. There was a recent post[1] on a similar
>> > issue that didn't end with much of a solution. Mike has had this
>> > detach/proxy business on his list of things he wanted to do for quite a
>> > time... :-)
>> >
>> > What version of OpenJPA are you running with?
>> >
>> > If you're running 2.0.0 or later and you're in need of a workaround in
>> the
>> > short term and depending on how your application is structured,
>> enabling
>> > LiteAutoDetach[2] might get you by this problem. The only reason I'm
>> > suggesting this property as I know that it will remove all proxies on
>> > EntityManager.close().
>> >
>> > [1] http://openjpa.markmail.org/thread/sczpivhncne27co4
>> > [2]
>> >
>> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_detach_state---
>> > openjpa.DetachState=loaded(LiteAutoDetach=true)
>> >
>> > Thanks,
>> > Rick
>> >
>> > On Sat, Apr 9, 2011 at 6:55 AM, Jason Ferguson > >wrote:
>> >
>> >> Sorry if this is a frequently asked question.
>> >>
>> >> I have an entity, Location, which has a bidirectional
>> >> OneToMany/ManyToOne relationship with another entity, BorderPoint.
>> >> Both entities implement Serializable and IsSerializable.
>> >>
>> >> The BorderPoint collection within the Location object is an ArrayList.
>> >> Unfortunately, OpenJPA uses a proxy class which is not serializable by
>> >> GWT. I've tried annotating both entities with
>> >> @DetachedState(enabled=true) with no luck.
>> >>
>> >> Can anyone assist?
>> >>
>> >> Jason
>> >>
>> >
>>
>
>


Re: OpenJPA and GWT Serialization

2011-04-11 Thread Michael Dick
Hi Jason,

Detachment and proxy classes are fairly complicated in OpenJPA. Like Rick
mentioned I've started looking at what it'd take to remove the proxies and
it's turned into a more sizable effort than I'd hoped.

OpenJPA was originally designed with JEE application servers in mind and it
answers that need well. Geronimo, WebSphere, and at least some versions of
WebLogic use OpenJPA as the basis for their persistence framework.

Outside of that area OpenJPA may require some massaging.

There has been some work done with GWT. The OpenTrader example :
http://openjpa.apache.org/opentrader.html uses some parts of GWT, but the
documentation is a little light in places. The source code is available
though, and may be of some help (I have no experience with GWT and can't
really judge).

HTH
-mike

On Sat, Apr 9, 2011 at 6:18 PM, Jason Ferguson wrote:

> I'm running with 2.1.0.  I figured if I was going to learn to use JPA
> versus Hibernate, I may as well use the most current version.
>
> So let me see if I'm doing this right. I added the following property
> to persistence.xml:
>
> 
>
> The docs seem to recommend adding a version field, which I haven't
> done yet. I also choose "loaded" versus "fetch-group" because I hadn't
> defined any custom fetch groups.
>
> With no offense intended towards the developers, I'm getting the
> impression that OpenJPA is currently not the right choice for a GWT
> project, until this particular issue is resolved.
>
> Jason
>
>
> On Sat, Apr 9, 2011 at 7:43 AM, Rick Curtis  wrote:
> > Jason -
> >
> >> Sorry if this is a frequently asked question.
> > This isn't a frequent question... yet. It seems that this issue has come
> up
> > a number of times on users/dev. There was a recent post[1] on a similar
> > issue that didn't end with much of a solution. Mike has had this
> > detach/proxy business on his list of things he wanted to do for quite a
> > time... :-)
> >
> > What version of OpenJPA are you running with?
> >
> > If you're running 2.0.0 or later and you're in need of a workaround in
> the
> > short term and depending on how your application is structured,
> enabling
> > LiteAutoDetach[2] might get you by this problem. The only reason I'm
> > suggesting this property as I know that it will remove all proxies on
> > EntityManager.close().
> >
> > [1] http://openjpa.markmail.org/thread/sczpivhncne27co4
> > [2]
> >
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_detach_state---
> > openjpa.DetachState=loaded(LiteAutoDetach=true)
> >
> > Thanks,
> > Rick
> >
> > On Sat, Apr 9, 2011 at 6:55 AM, Jason Ferguson  >wrote:
> >
> >> Sorry if this is a frequently asked question.
> >>
> >> I have an entity, Location, which has a bidirectional
> >> OneToMany/ManyToOne relationship with another entity, BorderPoint.
> >> Both entities implement Serializable and IsSerializable.
> >>
> >> The BorderPoint collection within the Location object is an ArrayList.
> >> Unfortunately, OpenJPA uses a proxy class which is not serializable by
> >> GWT. I've tried annotating both entities with
> >> @DetachedState(enabled=true) with no luck.
> >>
> >> Can anyone assist?
> >>
> >> Jason
> >>
> >
>


Re: Javadoc page is out of date

2011-04-08 Thread Michael Dick
I'm fine with getting rid of the page. There's a lot of old information on
the website and it could do with some reorganization. Hopefully this will be
easier once we've migrated to the Apache CMS.

The specific issue appears to be just getting confluence to export the page
properly. When I edit the javadoc page it has the right content, but the
static copy on the server isn't being updated. This should also be addressed
by the CMS.

-mike


On Fri, Apr 8, 2011 at 2:24 AM, Miłosz Tylenda  wrote:

> Hi Mike,
>
> javadoc.html is referenced from the Development page. Since it contains
> roughly the same content as documentation.html, I suggest we get rid of
> javadoc.html and link only to documentation.html.
>
> Regards,
> Milosz
>
>
> > The main documentation page
> > <http://openjpa.apache.org/documentation.html>has the correct links,
> > I'm not sure how the /javadoc.html page gets pulled
> > together though.
> >
> > In the mean time try these links :
> > 2.2.0-SNAPSHOT Javadoc :
> > http://openjpa.apache.org/builds/latest/docs/javadoc/index.html
> > 2.1.0-SNAPSHOT Javadoc:
> >
> http://openjpa.apache.org/builds/apache-openjpa-2.1.1-SNAPSHOT/docs/javadoc/index.html
> > 2.1.0 JavaDoc :
> >
> http://openjpa.apache.org/builds/2.1.0/apache-openjpa-2.1.0/docs/javadoc/index.html
> >
> > -mike
> >
> > On Thu, Apr 7, 2011 at 8:56 AM, Michael Dick  >wrote:
> >
> > > Hi Henno,
> > >
> > > Thanks for letting us know. I thought I updated that page after the
> > > release, but I must have missed it. The links should be fixed later
> this
> > > morning (afternoon in the Netherlands).
> > >
> > > -mike
> > >
> > > On Thu, Apr 7, 2011 at 3:43 AM, Henno Vermeulen <
> he...@huizemolenaar.nl>wrote:
> > >
> > >> Hello,
> > >>
> > >> Maybe you are already aware of this, but just in case... The javadoc
> page
> > >> at http://openjpa.apache.org/javadoc.html is out of date, it shows
> > >> 2.1.0-SNAPSHOT as the latest version but when I click this it opens
> the
> > >> documentation for 2.2.0-snapshot and there is no link to the 2.1.0
> release
> > >> documentation.
> > >>
> > >> Regards,
> > >> Henno Vermeulen
> > >> Huize Molenaar
> > >>
> > >
> > >
> >
>


Re: Need help to understand how getDirtyObjects() works.

2011-04-07 Thread Michael Dick
Hi Chintan,


What you're trying to do is (in my opinion) a gray area. You have a
stateless EJB, but are expecting the EntityManager to track the state of a
set of entities between method calls. If you start a transaction before
calling read() and that transaction is still active when you call update()
your scenario might work. It depends on the application server to associate
a specific EntityManager instance with a transaction (I think most app
servers do this but I could be all wet).

In general if you want an EntityManager to track a set of entities across
method invocations I find it more intuitive to use a Stateful bean, which
guarantees that the same instance of the bean (and EntityManager) will be
used throughout a conversation.

Hope this helps,
-mike


On Wed, Apr 6, 2011 at 11:51 PM, chintan4181  wrote:

> Read and Update are two functions exposed as a part of web service.
>
> In first step web service client call read service to get the data.
> in second step it may update values and call update service. and both of
> these methods are part of @stateless EJB.
>
> I think they will not part of same entity. please correct me if i m wrong.
>
> What should be the approach to identify dirty fields/objects?
>
> Thanks
> chintan
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Need-help-to-understand-how-getDirtyObjects-works-tp6239101p6248646.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Javadoc page is out of date

2011-04-07 Thread Michael Dick
The main documentation page
<http://openjpa.apache.org/documentation.html>has the correct links,
I'm not sure how the /javadoc.html page gets pulled
together though.

In the mean time try these links :
2.2.0-SNAPSHOT Javadoc :
http://openjpa.apache.org/builds/latest/docs/javadoc/index.html
2.1.0-SNAPSHOT Javadoc:
http://openjpa.apache.org/builds/apache-openjpa-2.1.1-SNAPSHOT/docs/javadoc/index.html
2.1.0 JavaDoc :
http://openjpa.apache.org/builds/2.1.0/apache-openjpa-2.1.0/docs/javadoc/index.html

-mike

On Thu, Apr 7, 2011 at 8:56 AM, Michael Dick wrote:

> Hi Henno,
>
> Thanks for letting us know. I thought I updated that page after the
> release, but I must have missed it. The links should be fixed later this
> morning (afternoon in the Netherlands).
>
> -mike
>
> On Thu, Apr 7, 2011 at 3:43 AM, Henno Vermeulen wrote:
>
>> Hello,
>>
>> Maybe you are already aware of this, but just in case... The javadoc page
>> at http://openjpa.apache.org/javadoc.html is out of date, it shows
>> 2.1.0-SNAPSHOT as the latest version but when I click this it opens the
>> documentation for 2.2.0-snapshot and there is no link to the 2.1.0 release
>> documentation.
>>
>> Regards,
>> Henno Vermeulen
>> Huize Molenaar
>>
>
>


Re: Javadoc page is out of date

2011-04-07 Thread Michael Dick
Hi Henno,

Thanks for letting us know. I thought I updated that page after the release,
but I must have missed it. The links should be fixed later this morning
(afternoon in the Netherlands).

-mike

On Thu, Apr 7, 2011 at 3:43 AM, Henno Vermeulen wrote:

> Hello,
>
> Maybe you are already aware of this, but just in case... The javadoc page
> at http://openjpa.apache.org/javadoc.html is out of date, it shows
> 2.1.0-SNAPSHOT as the latest version but when I click this it opens the
> documentation for 2.2.0-snapshot and there is no link to the 2.1.0 release
> documentation.
>
> Regards,
> Henno Vermeulen
> Huize Molenaar
>


Re: Documentation on setting a field strategy in XML

2011-04-07 Thread Michael Dick
Hi Jared,

Currently there is no way to set an OpenJPA specific annotation via XML. We
are working on fixing this, take a look at
OPENJPA-1971for
the details.

-mike

On Thu, Apr 7, 2011 at 6:12 AM, Jared Pearson wrote:

> I'm trying to find information on setting a field strategy using XML.  I
> understand that openjpa.jdbc.MappingDefaults defines a type to a Strategy
> but I need a specific field to Strategy.  In annotations, you would use
> @Strategy on the field.
>
> Thank you.
> Jared
>


Re: Issues with GeneratedValue and SequenceGenerator

2011-04-06 Thread Michael Dick
Well, I was able to reproduce if I do the following

1. Create the database tables.
2. Run the PCEnhancer with BaseEntity and MyEntity in the persistence.xml
3. Remove BaseEntity from persistence.xml
4. Persist a new instance of MyEntity.

I've only reproduced with IDENTITY, but it should be similar with SEQUENCE.

Otherwise I've had no luck. Based on your results it sounds like the
database was not created properly, but that's just a guess.

-mike

On Wed, Apr 6, 2011 at 2:46 PM, realdepp  wrote:

> Yes, MyBase is in persistence.xml.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Issues-with-GeneratedValue-and-SequenceGenerator-tp6244055p6247366.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Issues with GeneratedValue and SequenceGenerator

2011-04-06 Thread Michael Dick
Is the MyBase class listed in persistence.xml?

-mike

On Wed, Apr 6, 2011 at 1:54 PM, realdepp  wrote:

> MySQL version is 4.1.22
> Connector version is 5.1.8, JDBC version is documented as 4.0
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Issues-with-GeneratedValue-and-SequenceGenerator-tp6244055p6247210.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Possible to ignore FK constraints?

2011-04-06 Thread Michael Dick
Hi Chris,

It looks like you're using the openjpa.jdbc.SynchronizeMappings property
(with ForeignKeys=true). Could you verify whether that is the case in your
environment?

This setting is useful during application development, but you probably
don't want to use this setting in your production environment. When it's
enabled OpenJPA may attempt to update the table definitions to match your
entities.

HTH

-mike

On Tue, Apr 5, 2011 at 12:49 PM, Rick Curtis  wrote:

> Chris -
>
> Can you paste the exception that you are seeing?
>
> Thanks,
> Rick
>
> On Sun, Apr 3, 2011 at 1:21 PM, Chris Lennert  wrote:
>
> > Is it possible to instruct OpenJPA to ignore foreign keys to unmapped
> > tables
> > that may exist in the database?
> >
> > My situation:  Large ERP database (thousands of tables) that I'm only
> > reading (never inserting or updating) data from.  My app only is only
> > concerned with reading records from two tables.  One of the tables has
> > numerous foreign key constraints, all of which are outside the scope of
> my
> > app.  Thus, my entity bean class defines only the fields from that table
> > I'm
> > interested in.  Unfortunately, the app blows up when OpenJPA queries the
> > database to determine the constraints that exist on that table and
> promptly
> > complains about unmapped FK constraints.
> >
> > I'm hoping that I can do this without creating entity beans for all these
> > other tables.
> >
> > Thanks for any help you can offer,
> > Chris
> >
>


Re: Help Persisting a List

2011-04-06 Thread Michael Dick
I'm going to ask Risk's standard question, how are you doing enhancement?

Can you narrow down the scope of the problem, e.g. does the problem happen
on every insert, or is it something that only happens when the list is
large?

-mike


On Tue, Apr 5, 2011 at 4:28 PM, Jason Ferguson wrote:

> I have two Entities: Location and BorderPoint. Location contains a
> List of BorderPoint, with a bidirectional mapping between them. The
> list containing the BorderPoints can be quite large (9,000 is not
> unheard of). Unfortunately, the attempt to persist a list fails with
> the following exception:
>
> [ERROR] org.apache.openjpa.persistence.ArgumentException: Attempt to
> assign id "0" to new instance
> "org.jason.mapmaker.shared.model.BorderPoint@3134a2" failed; there is
> already an object in the L1 cache with this id. You must delete this
> object (in a previous transaction or the current one) before reusing
> its id. This error can also occur when a horizontally or vertically
> mapped classes uses auto-increment application identity and does not
> use a hierarchy of application identity classes.
>
>
> I read the data from an ESRI Shapefile in two passes. The first pass
> persists all locations in the Shapefile, then I come back and read the
> geometry stored in the Shapefile into the BorderPoint list. The code
> to actually persist the List of BorderPoint objects tries to break up
> the commit into batches of 100.
>
> The call to persist the Locations and BorderPoint objects looks like this:
>
>for (String typeName : typeNames) {
>
>FeatureSource featureSource;
>FeatureCollection featureCollection;
>
>try {
>featureSource = dataStore.getFeatureSource(typeName);
>featureCollection = featureSource.getFeatures();
>
>saveLocations(featureCollection);
>saveBorderPoints(featureCollection);
>
>} catch (IOException e) {
>throw new ServiceException("processShapefile() threw
> IOException", e);
>}
>
>}
>
> The method to persist the borderPoints looks like this:
>
>private void saveBorderPoints(FeatureCollection featureCollection)
> throws ServiceException {
>
>FeatureIterator iterator = featureCollection.features();
>while (iterator.hasNext()) {
>
>SimpleFeatureImpl feature = (SimpleFeatureImpl) iterator.next();
>
>String geoId = (String) feature.getAttribute("GEOID10");
>
>Location location = locationRepository.getByGeoId(geoId);
>if (location == null) {
>throw new ServiceException("saveBorderPoints() threw
> ServiceException due to null Location");
>}
>MultiPolygon multiPolygon = (MultiPolygon)
> feature.getDefaultGeometry();
>Geometry geometry = multiPolygon.getBoundary();
>
>// Create the result list. Set initial capacity size to
> number of actual points in the geometry to avoid some
>// overhead when dealing with the list
>List borderPointList = new
> ArrayList(geometry.getNumPoints());
>
>// cycle through the coordinates to create the border points
>Coordinate[] coordinates = geometry.getCoordinates();
>for (Coordinate c : coordinates) {
>BorderPoint borderPoint = new BorderPoint();
>borderPoint.setLocation(location);
>borderPoint.setLng(new BigDecimal(c.x));
>borderPoint.setLat(new BigDecimal(c.y));
>
>borderPointList.add(borderPoint);
>}
>
>try {
>borderPointRepository.persistList(borderPointList);
>} catch (RepositoryException e) {
>throw new ServiceException("saveBorderPoints() threw
> RepositoryException", e);
>}
>}
>
>iterator.close();
>}
>
> and
>
>@Transactional
>public void persistList(List objectList) throws
> RepositoryException {
>
>EntityManager em = entityManagerFactory.createEntityManager();
>
>try {
>em.getTransaction().begin();
>int i = 1;
>for (BorderPoint bp : objectList) {
>em.persist(bp);
>if (i % 100 == 0) {
>em.flush();
>em.clear();
>}
>i++;
>}
>em.getTransaction().commit();
>} catch (EntityExistsException ex) {
>// need to log this somehow
>//log.warning("persist() threw EntityExistsException: " +
> ex.getMessage());
>ex.printStackTrace();
>throw new RepositoryException(ex);
>}
>catch (Exception e) {
>e.printStackTrace();
>} finally {
>em.close();
>}
>}
>
> Finally, here is the code for the BorderPoint class:
>
> @Entity
> @Table(name = "BORDERPOINT")
> public class BorderPo

Re: Issues with GeneratedValue and SequenceGenerator

2011-04-06 Thread Michael Dick
Rick's right, my memory was faulty. I think in the earlier versions of
OpenJPA a refresh was required, but when I ran with a 2.1.1 snapshot this
morning I didn't have to call refresh.

Thanks for keeping me honest Rick..

-mike

On Wed, Apr 6, 2011 at 9:45 AM, Rick Curtis  wrote:

> I'm guessing that this might have to do with your enhancement method? If
> you
> are using the eclipse plugin... that is most likely the problem. See
> OPENJPA-1879[1] for details.
>
> [1] https://issues.apache.org/jira/browse/OPENJPA-1879
>
> Thanks,
> Rick
>
> On Tue, Apr 5, 2011 at 5:36 PM, realdepp  wrote:
>
> > Hi!
> >
> > I'm working with OpenJPA 2.1.0 and have (simplified) the following
> > superclass. All "real" entities derive from that class:
> >
> > @MappedSuperclass
> > public abstract class MyBase {
> >private long id;
> >
> >@Id
> >@GeneratedValue(strategy = GenerationType.IDENTITY)
> >public final long getId() {
> >return id;
> >}
> >
> >public final void setId(long id) {
> >this.id = id;
> >}
> > }
> >
> > I'm persisting the classes with the following code:
> >
> >EntityTransaction et = em.getTransaction();
> >et.begin();
> >em.persist(myEntity);
> >et.commit();
> >// Huh!?
> >System.out.println(myEntity.getId() + " == 0");
> >
> > The System.out always sais "0 == 0", however in the database there is a
> > correct generated id.
> >
> > Am I missing something?
> >
> >
> > Another thing:
> >
> > The same scenario as above, but a different strategy for @GeneratedValue:
> >@Id
> >@SequenceGenerator(name = "My_Seq", initialValue = 10,
> > allocationSize = 1)
> >@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> > "My_Seq")
> >
> > The same error as above, but additionally, the "initialValue" is ignored,
> > the ID in the db starts with "1".
> > Did I trigger a bug or did I make a mistake?
> >
> >
> > Thanks a lot.
> >
> >
> >
>


Re: Issues with GeneratedValue and SequenceGenerator

2011-04-05 Thread Michael Dick
When you use GenerationType.IDENTITY or GenerationType.SEQUENCE the ID
values aren't known until the row is inserted. OpenJPA does not
automatically refresh this information, but you can obtain it if you use the
EntityManager.refresh() method.

Regarding intialValues, did OpenJPA create the sequence in the database? If
the sequence already exists OpenJPA will not update the definition (I think
even SynchronizeMappings will leave an existing Sequence alone). It might
help to manually drop and let OpenJPA recreate the sequence.

-mike

On Tue, Apr 5, 2011 at 5:36 PM, realdepp  wrote:

> Hi!
>
> I'm working with OpenJPA 2.1.0 and have (simplified) the following
> superclass. All "real" entities derive from that class:
>
> @MappedSuperclass
> public abstract class MyBase {
>private long id;
>
>@Id
>@GeneratedValue(strategy = GenerationType.IDENTITY)
>public final long getId() {
>return id;
>}
>
>public final void setId(long id) {
>this.id = id;
>}
> }
>
> I'm persisting the classes with the following code:
>
>EntityTransaction et = em.getTransaction();
>et.begin();
>em.persist(myEntity);
>et.commit();
>// Huh!?
>System.out.println(myEntity.getId() + " == 0");
>
> The System.out always sais "0 == 0", however in the database there is a
> correct generated id.
>
> Am I missing something?
>
>
> Another thing:
>
> The same scenario as above, but a different strategy for @GeneratedValue:
>@Id
>@SequenceGenerator(name = "My_Seq", initialValue = 10,
> allocationSize = 1)
>@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> "My_Seq")
>
> The same error as above, but additionally, the "initialValue" is ignored,
> the ID in the db starts with "1".
> Did I trigger a bug or did I make a mistake?
>
>
> Thanks a lot.
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Issues-with-GeneratedValue-and-SequenceGenerator-tp6244055p6244055.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: questions about FetchAttribute recursionDepth

2011-04-05 Thread Michael Dick
Hi Henno,

Have you set the openjpa.DetachState property or are you using the default
value?

-mike

On Tue, Apr 5, 2011 at 11:17 AM, Henno Vermeulen wrote:

> I suspect this is an issue with detaching!
>
> I turned on the trace and printed a message after entityManager.find.
> When I have a structure of 10 levels deep and fetch the deepest child,
> OpenJPA cleanly fetches the leaf ProductCategory with 1 query, then prints
> my message, but then starts recursively fetching all parents.
>
> When I set the recursionDepth to 2 the SQL shows that it fetches one more
> parent, then print my debug message, then fetch the rest.
>
> Is this a known problem or should I report this?
>
> Regards,
> Henno Vermeulen
> Huize Molenaar.
>
> -Oorspronkelijk bericht-
> Van: Henno Vermeulen [mailto:he...@huizemolenaar.nl]
> Verzonden: dinsdag 5 april 2011 17:42
> Aan: 'users@openjpa.apache.org'
> Onderwerp: questions about FetchAttribute recursionDepth
>
> I have a ProductCategory entity with a reference to a parent
> ProductCategory. I wish to eagerly fetch one parent but not the parent's
> parent. We always use fetchplans (using
> entityManager.getFetchPlan().addFetchGroups(...)) and we always detach
> according to the fetchplan, so I tried:
>
> @FetchGroup(name = "ProductCategoryParentNoRecursion", attributes = {
> @FetchAttribute(name = "parent", recursionDepth = 1) })
>
> Question 1: according to the latest manual a recursionDepth of 1 is the
> default, but I have also seen it mentioned in Jira or the newsgroup that it
> was changed so that the recursion depth has no limit by default. Which one
> is it?
>
> Question 2: no matter what recursionDepth I use (I tried -1, 0, 1 and 2),
> it always fetches the parent's parent. I tested this with a ProductCategory
> structure of A -> B -> C. When I use entityManager.find to find C by it's
> id, I expect C.parent.parent to be null but it is not. Why is this?
> (I did not access the parent before detaching).
>
> Regards,
>
> Henno Vermeulen
> Huize Molenaar
>


Re: making properties in persistence.xml dynamic

2011-03-31 Thread Michael Dick
The schema property is not used at compile time.

The easiest way to use a different schema is to use a jta-data-source in
your persistence.xml and set the appropriate schema on the datasource. I
think WebSphere allows the schema to be set as a custom property for their
datasources.

Will the schema be different for each server, or just different between dev
and production? If there are only a few values, you could create a
persistence unit for each schema, inject both contexts, and have the
application determine which one to use (kind of ugly).

Setting the property at EMF creation is also an option (it can be passed in
the property map AFAIK) - so long as you get the value before injection
occurs (or create the EMF yourself). An EntityManager created in this way
will use PersistenceContextType=extended. The application will also have to
be diligent  about closing the EntityManager when it's done using it.

You cannot, however, set the property when you create an EntityManager -
even if you do not use injection.

Regarding RAD - I suspect they pick up the same version of OpenJPA that WAS
uses. I can't say how often they refresh it though, so it might be a little
behind the snapshots we publish.

Hope this helps, or is at least a starting point.

-mike


On Thu, Mar 31, 2011 at 5:00 PM, areider  wrote:

> I need to deploy one Enterprise Application Repository (EAR) file across
> multiple Websphere servers, eg a development,test,QA,and production server,
> where the schema name varies depending on the server. This is actually a
> legal or regulatory requirement - the EAR file deployed to production must
> be the same EAR file that was deployed and test in QA, with no intervening
> changes.
>
> For internal frameworks, we generally 'dynamicize' properties in the EAR by
> having a separate named folder the property file for each environment.
> Then,
> runtime startup code can 'select' the  folder based on a JNDI value defined
> on each server. That is not obviously not going to work for JPA and
> persistence.xml. Is the schema property used at compile time? If so, that
> would seem to rule out any possibility of making it dynamic.
>
> I also looked at overriding the persistence.xml properties at runtime, eg
> using an EntityManagerFactory instead of EntityManager injection, which
> allows passing a property map. The problems i hit there, were that the EMF
> method signatures in the documentation for 1.2.3_Snapshot (this is on
> (Eclipse-based) Rad 7.5.5) did not seem to match the code,  plus I could
> not
> figure out what the analog of the PersistenceContextType attribue of the
> @PersistenceContext annotation is when using EMF vs injection; also i was
> not sure if openjpa.jdbc properties could be passed; also I got the
> impression that EM's created using an EMF might not behave in exactly the
> same way as injected ones in terms of the persistenceContextType (eg the
> EMs
> would always be PersistenceContextType=extended?)
>
> Is there any available solution for deploying the same EAR to different
> servers and having JPA pick up a different schema value (and possibly other
> properties) depending on a JNDI value or other value that varies per
> server?
> I read that persistence.xml just has to be on the classpath,  so possibly
> it
> could be external to the EAR, but that could be problematic since not all
> the servers support symlinks (at least one is a windows server).
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/making-properties-in-persistence-xml-dynamic-tp6228861p6228861.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Read Multiple Resultset from Stored Proc call using Open JPA

2011-03-31 Thread Michael Dick
You're welcome.

I belatedly found that we cover getting a connection manually in the user
manual too :
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_sqlconn
.

-mike

On Thu, Mar 31, 2011 at 6:43 PM, chintan4181  wrote:

> thanks Michale. Got you!!
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Read-Multiple-Resultset-from-Stored-Proc-call-using-Open-JPA-tp6223507p6228982.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Read Multiple Resultset from Stored Proc call using Open JPA

2011-03-31 Thread Michael Dick
No problem - we were all new once.

I probably shouldn't have suggested using the same connection as the
EntityManager. Getting the connection from an EntityManager instance is kind
of hack and it will tie you to a specific JPA vendor (OpenJPA in your case).
Generally a better solution when you're running in a JEE container is to
obtain a connection from a managed datasource.

Say you have a persistence.xml like this :


 . . .
 jdbc/myDataSource
  . . .


Then in your application where you have the persistence context you would do
something like this :

InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("jdbc/myDataSource");  // same name
as persistence.xml
Connection con = ds.getConnection();
con.prepareCall(. . . );
con.close();

The reason this works is because most JEE containers will attempt to share a
single connection within a JTA transaction. So the EntityManager you
injected, and the connection from the DataSource will _usually_ be the same.
There are some conditions where the container can't share a connection (e.g.
if the isolation level has been changed), and each application server may
handle these cases slightly differently.

If you still want to use the same connection as the EntityManager there are
instructions on this thread: http://markmail.org/message/pwoare2l76rqonws

Best Regards,

-mike


On Thu, Mar 31, 2011 at 2:59 PM, chintan4181  wrote:

> Thnak Michale.
>
> When you say Manually, you mean to get the connection from EntityManager
> and
> use callableStatement?
> If yes, can you show me how to get connection from EntityManagerFactory?
>
> I am using @persistentContext and get the EntityManager out of it. I don't
> see any method for getting JDBC conenction.
>
> I am new to JPA so sorry for the simple question.
>
> Thanks
> Chintan
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Read-Multiple-Resultset-from-Stored-Proc-call-using-Open-JPA-tp6223507p6228576.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: Read Multiple Resultset from Stored Proc call using Open JPA

2011-03-30 Thread Michael Dick
Hi Chintan,

This has come up before and the net was that we could not support multiple
result sets without some help (or changes) from the specification.

There's a bit more information in
OPENJPA-918,
but unfortunately right now you're best advice is to run the stored
procedure manually.

Some people have had luck by obtaining the connection used by the
EntityManager and executing the stored procedure there (in particular take a
look at this 
threadfrom
earlier today).

Hope this helps
-mike


On Wed, Mar 30, 2011 at 10:12 AM, chintan4181  wrote:

> Hi,
>
> I am using openJPA 2.0 and calling SQL sever stored procedure using
> CreateNativeQuery. My stored proc is returning multiple resultset. When i
> use Query.getResultList(), it returns me only first result set. rest of the
> result sets i can not see.
>
> Is there a way to get the multiple result set return by Stored procedure
> from OpenJPA api?
>
> Your help will be highly appreicated.
>
> Thanks
> Chintan
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Read-Multiple-Resultset-from-Stored-Proc-call-using-Open-JPA-tp6223507p6223507.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Re: NPE with Fetch Join Query

2011-03-30 Thread Michael Dick
Hi Tobias,

Which version of OpenJPA are you using?

It looks like we don't have a cached version of the metadata for type B,
enabling 
preloadingof
the meta data might at least work around the problem.

-mike

On Wed, Mar 30, 2011 at 5:22 AM, Tobias Trelle  wrote:

> Hi,
>
> I have a lazy loading 1:n association. I'd like to write a query to eager
> fetch that association on demand.
>
>
> @Entity
> @NamedQueries(@NamedQuery(name = "fetchB", query = "SELECT a from A a LEFT
> JOIN FETCH a.b WHERE a.id = :id"))
> public class A {
>
>@Id
>private long id;
>
>private String name;
>
>@OneToMany(fetch = FetchType.LAZY)
>@JoinColumn(name = "FIRMA_ID")
>private Collection b;
>...
>
> @Entity
> public class B {
>
>@Id
>private long id;
>
>private String name;
>   ...
>
>
>
> When I execute the named query ...
>
>
> A a = em.createNamedQuery("fetchB", A.class).setParameter("id",
> 42).getSingleResult();
>
>
> ... the following SQL statement is executed against the database:
>
> SELECT t0.id, t0.name, t1.FIRMA_ID, t1.id, t1.name
>FROM S.A t0 LEFT OUTER JOIN S.B t1 ON t0.id = t1.FIRMA_ID
>WHERE (t0.id = ?) optimize for 1 row
>
> If I execute it with my favourite SQL tool, I get a result set of size 2.
>
> OpenJPA throws a NullpointerException:
>
>
>  org.apache.openjpa.persistence.PersistenceException: null
> FailedObject: SELECT a from A a LEFT JOIN FETCH a.b WHERE a.id = :id
> [java.lang.String]
>at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:986)
>at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:885)
>at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1030)
>at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
>at
>
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2344)
>at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
>at
>
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
>at
> org.apache.openjpa.lib.rop.EagerResultList.(EagerResultList.java:36)
>at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1246)
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:861)
>at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:792)
>at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:288)
>at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
>at
>
> org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:326)
>at
> JpaFetchTestManual.testFindQuery(JpaFetchTestManual.java:58)
>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:585)
>at junit.framework.TestCase.runTest(TestCase.java:168)
>at junit.framework.TestCase.runBare(TestCase.java:134)
>at junit.framework.TestResult$1.protect(TestResult.java:110)
>at junit.framework.TestResult.runProtected(TestResult.java:128)
>at junit.framework.TestResult.run(TestResult.java:113)
>at junit.framework.TestCase.run(TestCase.java:124)
>at junit.framework.TestSuite.runTest(TestSuite.java:232)
>at junit.framework.TestSuite.run(TestSuite.java:227)
>at
>
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>at
>
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>at
>
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.NullPointerException
>at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setInverseRelation(JDBCStoreManager.java:469)
>at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:429)
>at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:322)
>at
>
> org.apache.openjpa.kernel.DelegatingSt

Re: Stuck threads at Schema.getTable.

2011-03-28 Thread Michael Dick
Hi Ravi,

The link didn't work for me, is this a bug in the TreeMap implementation?

Multithreaded reads of a TreeMap should be fine. If a thread is adding or
deleting a node then we'll need to synchronize - is that what's happening in
your case?

I've cross posted to dev - might get a better audience there.

-mike

On Sun, Mar 27, 2011 at 10:06 PM, Ravi P Palacherla <
ravi.palache...@oracle.com> wrote:

> Hi ,
>
> I see following stuck threads in openJPA code :
>
>  java.lang.Thread.State: RUNNABLE
>   at java.util.TreeMap.getEntry(TreeMap.java:328)
>   at java.util.TreeMap.get(TreeMap.java:255)
>   at org.apache.openjpa.jdbc.schema.Schema.getTable(Schema.java:115)
>
> I think the root cause of the issue is because of unsynchronized TreeMap.
>
> There is a sun issue that explains the same about a hashMap and I think
> this
> is also because of the same issue explained in:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6423457
>
> So, the fix is to synchronize the TreeMap but I do not have a replicable
> test case.
>
> I created a simple testcase that will create around 10 treeMap entries
> and then around 50 threads trying to access this treeMap but unable to
> replicate the issue.
>
> Please suggest what you think should be done.
> Can I just submit the code fix ( synchronizing the treemap) and the test
> case ( even though unable to replicate ) ?
>
> Regards,
> Ravi.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Stuck-threads-at-Schema-getTable-tp6213602p6213602.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


  1   2   3   4   5   6   >