OpenJPA replaces a collection field

2009-04-29 Thread Paul Copeland
Here is an OpenJPA 1.2.1 example that demonstrates the OpenJPA replaces a collection field problem. This may not be technically a bug but it can be a problem for the unaware user. This happens with a new persisted object with a collection field that is initially null. If the null collection

Re: OpenJPA replaces a collection field

2009-04-29 Thread Paul Copeland
.jar - Paul On 4/29/2009 8:56 AM, Craig L Russell wrote: Hi Paul, Thanks for following up on this. On Apr 28, 2009, at 11:19 PM, Paul Copeland wrote: Here is an OpenJPA 1.2.1 example that demonstrates the OpenJPA replaces a collection field problem. This may not be technically a bug but it can

How to defer updating of collection

2009-04-29 Thread Paul Copeland
Hi - I was attempting a too clever scheme to defer adding to a collection that has not been lazy loaded yet. The code in the isPropertyLoaded() method below was posted by an expert on this list a while ago. It works - it returns true if the field has been loaded. But the problem is that

Re: Open JPA recommended driver for DB2

2009-04-27 Thread Paul Copeland
Hi Chandra - XA is a standard for distributed transactions and usually refers to situations where multiple databases are used in a combined transaction. This is a big subject. You might get a start here - http://en.wikipedia.org/wiki/X/Open_XA - Paul On 4/27/2009 10:03 AM,

Re: Performance issues

2009-04-26 Thread Paul Copeland
: Right. So, you're saying that it's not possible to do one batch transaction with the DB when there are joins involved? Thanks, =David On Thu, 2009-04-23 at 21:06 -0700, Paul Copeland wrote: It makes sense that it would do a query per primary key (all in a single transaction

Re: Performance issues

2009-04-23 Thread Paul Copeland
at 13:49 +0900, David Leangen wrote: Thank you, I'll give that a try. On Fri, 2009-04-17 at 07:55 -0700, Paul Copeland wrote: That sounds interesting. You might turn on verbose logging for SQL operations (openjpa.jdbc.SQL) and see what queries are actually being executed

Re: Problems in setting up the work enviroment.

2009-04-22 Thread Paul Copeland
On Tue, Apr 21, 2009 at 12:56 PM, Paul Copeland t...@jotobjects.com wrote: Can you get it to work without Maven and without Eclipse first? You should be able to (1) download OpenJPA 1.2.1, (2) cd to examples/hellojpa, (3) type ant That should be all you have

Re: Problems in setting up the work enviroment.

2009-04-21 Thread Paul Copeland
Can you get it to work without Maven and without Eclipse first? You should be able to (1) download OpenJPA 1.2.1, (2) cd to examples/hellojpa, (3) type ant That should be all you have to do. If that does not end in BUILD SUCCESSFUL please send the output to this list. Once you have that

Re: Performance issues

2009-04-17 Thread Paul Copeland
That sounds interesting. You might turn on verbose logging for SQL operations (openjpa.jdbc.SQL) and see what queries are actually being executed. The logging section of the OpenJPA manual explains this. On 4/17/2009 3:41 AM, David Leangen wrote: Hello, I'm not at all an expert in

Re: cascading deletes and entity relationship constraints

2009-04-15 Thread Paul Copeland
Hi Adam - JIRA-39 is pretty old. Possibly JIRA-1004 is related to your question? There was recent discussion on this list about this. Also there was recent mention on this list of using either one of these settings regarding ordering of operations (reading the docs leaves me with some

Re: persistence problem in distributed environment

2009-04-13 Thread Paul Copeland
Does the test below fail for you? It works correctly for Ravi. Can you send an example that demonstrates the problem? On 4/13/2009 8:08 AM, hmmahboobi wrote: Hi Thanks for your response, This model is a small view of our large system, Actual codes are very large and complex, so I cant send

Re: Does OpenJPA replace Collections?

2009-04-13 Thread Paul Copeland
to the database (even though persist() has been called) the value could be null rather than an empty collection. So the behavior of OpenJPA returning null (assertion #1) would be consistent with the spec. - Paul On 4/9/2009 12:22 PM, Paul Copeland wrote: Thanks for the assistance Craig - Here

Re: Does OpenJPA replace Collections?

2009-04-13 Thread Paul Copeland
are holding a reference to the value returned by getMyPcList() that collection will then be stale, possibly leading to inconsistent results for the caller. - Paul (other comments below) On 4/13/2009 4:18 PM, Craig L Russell wrote: Hi Paul, On Apr 13, 2009, at 9:04 AM, Paul Copeland wrote

Re: Does OpenJPA replace Collections?

2009-04-13 Thread Paul Copeland
, On Apr 13, 2009, at 5:15 PM, Paul Copeland wrote: Craig - Thanks for the responses. This confirms that for a new Entity a collection field may be null unless the application initializes it. When you say flushed does that include calling EntityManager.flush() before the transaction is committed

Re: persistence problem in distributed environment

2009-04-11 Thread Paul Copeland
unmanaged means the Account object assigned to the ManyToOne field is new and not yet persistent, removed, or detached. On 4/11/2009 7:46 AM, rpalache wrote: Hi, Set the cascade attribute for this field to CascadeType.PERSIST or CascadeType.ALL (JPA annotations) or persist or all (JPA

Re: OneToMany update issue

2009-04-11 Thread Paul Copeland
Hi Stefan - I think your A.SetB(B) method must call B.add(A) From section 2.1.7 in JPA Specification - Note that it is the application that bears responsibility for maintaining the consistency of runtime relationships---for example, for insuring that the one and the many sides of a

Re: Does OpenJPA replace Collections?

2009-04-09 Thread Paul Copeland
metric. Considering everything, I still recommend that you instantiate an empty collection when you construct an entity. Craig On Apr 8, 2009, at 10:21 AM, Paul Copeland wrote: Pinaki - I tried your suggestion of not initializing the value of myPcList and I get a null pointer exception when

Re: inefficient mapping

2009-04-09 Thread Paul Copeland
um 20:03 schrieb Paul Copeland: Marc - If all the join columns are indexed it should not be too slow. You could put the same SQL into an explain analysis tool to investigate it. For a start run the SQL outside JPA and see how many rows are returned. Notice you are getting an orderpos

Re: Does OpenJPA replace Collections?

2009-04-09 Thread Paul Copeland
to the collection). If the experts believe either of these assertions are incorrect then I definitely want to investigate further. - Paul (further comments below) On 4/9/2009 11:13 AM, Craig L Russell wrote: Hi Paul, On Apr 9, 2009, at 9:40 AM, Paul Copeland wrote: Couple of clarifications

Does OpenJPA replace Collections?

2009-04-08 Thread Paul Copeland
Can OpenJPA replace a Collection when it is loaded? With the code below when the list is initially empty you need to create a List (ArrayList) so you can add elements to it. When I persisted new objects on the ManyToOne side and added them to the List that worked. But the first time the List

Re: Does OpenJPA replace Collections?

2009-04-08 Thread Paul Copeland
(java.util.ArrayList.class, list.getClass()); list.add(new MyPcObject()); owner.setMyPcList(list); On Apr 7, 2009, at 11:10 PM, Paul Copeland wrote: Can OpenJPA replace a Collection when it is loaded? With the code below when the list is initially empty you need to create a List (ArrayList

Re: Does OpenJPA replace Collections?

2009-04-08 Thread Paul Copeland
. - Paul On 4/8/2009 9:43 AM, Paul Copeland wrote: Thanks Pinaki - I think you are saying that at some point the proxy object does replace the local List. Is that right? I have seen that model - if (myPcList == null) myPcList = new ArrayList() - in various examples (not sure where now). Thanks

Re: inefficient mapping

2009-04-08 Thread Paul Copeland
gr. --- regards Marc Logemann http://www.logemann.org http://www.logentis.de Am 08.04.2009 um 06:49 schrieb Paul Copeland: Hi Marc - I wonder what kind of database schema that produces. Normally you would have OneToMany on one side and ManyToOne on the other side, with the mappedBy

Re: Pattern for unmodifiable Collections

2009-04-08 Thread Paul Copeland
Thanks for the feedback. Judes suggestion looks promising for ManyToMany case but could complicate my forward mapping. Pinaki - Your suggestion sort of works ... because it creates a new unmodifiableList every time getMyPcList() is called -- there is a constructor invoked inside

Re: zero length file using

2009-04-07 Thread Paul Copeland
to define the classes you want to map. I am using the classes listed in persistence.xml which is why I need to specify a persistence-unit on the command line. - Pau|l| On 4/7/2009 7:16 AM, Edoardo Panfili wrote: Il 6-04-2009 18:14, Paul Copeland ha scritto: Hello Edoardo - I got this to work

Pattern for unmodifiable Collections

2009-04-07 Thread Paul Copeland
I am trying to provide JPA persistent objects in a framework. If I return a ManyToMany Collection the user has to understand what side is the mappedBy owner and be careful to update both sides. There are other reasons for wanting to restrict updates to OneToMany relations. Is there a way to

Re: Identity class and parent/children entity relationship

2009-04-07 Thread Paul Copeland
Is there a workaround for 1.2.1? I'm also hitting the reentrant flush exception with GenerationType.IDENTITY On 3/30/2009 10:26 AM, Nemanja Joksovic wrote: Thanks Fay, I tried it before and it's working fine. But in production environment I need to using stable OpenJPA 1.2.x version (JPA

Re: Identity class and parent/children entity relationship

2009-04-07 Thread Paul Copeland
are. I already tried doing flushes. Maybe I need to do a refresh too? - Paul On 4/7/2009 1:51 PM, Fay Wang wrote: The fix is in JIRA-1004. I only checked in the fix to trunk, not 1.2.x, though. -Fay - Original Message From: Paul Copeland t...@jotobjects.com To: users

Re: inefficient mapping

2009-04-07 Thread Paul Copeland
Hi Marc - I wonder what kind of database schema that produces. Normally you would have OneToMany on one side and ManyToOne on the other side, with the mappedBy on the OneToMany side. This is the classical way the foreign keys work in relational database models. I think you do not need

Where to get general JPA help

2009-04-07 Thread Paul Copeland
Are there other forums or lists that are good for asking general JPA questions (not specifically OpenJPA)? - Paul

Re: zero length file using

2009-04-06 Thread Paul Copeland
Hello Edoardo - I got this to work with Ant and OpenJPA 1.2.1 similar to what you are doing with schemaAction=build and sqlFile=abc.sql (without action element). However I gave up on the taskdef when I found that I could not specify java arguments and sysproperty values to the Ant task. I

Docs confusion/bug openjpa.jdbc.MappingDefaults

2009-04-04 Thread Paul Copeland
There seems to a minor confusion in the 1.2.1 OpenJPA manual regarding openjpa.jdbc.MappingDefaults Section 7.4 Reference Guide - I discovered by trial and error that the jpa alias is the default and the default alias is NOT the default. Using the jpa alias generates the same forward mapping

Re: Behavior if ManyToMany CascadeType.REMOVE

2009-04-03 Thread Paul Copeland
specification. The cascade=REMOVE specification should only be applied to associations that are specified as One- ToOne or OneToMany. Applications that apply cascade=REMOVE to other associations are not portable. On 4/3/2009 10:43 AM, Paul Copeland wrote: Will CascadeType.REMOVE on a ManyToMany mapping

Re: Behavior if ManyToMany CascadeType.REMOVE

2009-04-03 Thread Paul Copeland
Looks like I can use the OpenJPA @ForeignKey annotation deleteAction=CASCADE - will give it a try. On 4/3/2009 11:18 AM, Paul Copeland wrote: This is from the JPA spec - Sounds like cascade=REMOVE should not be used on ManyToMany. However I'm recalling that some databases do provide DDL

Re: Inconsistent behaviour with Bi-directional One to Many Mapping.

2009-04-02 Thread Paul Copeland
inconsistent.. I made the following changes to the mapping.. @ManyToOne (optional=false, CascadeType.ALL) Is this a defect? Best regards, Srini On Wed, Apr 1, 2009 at 11:20 PM, Paul Copeland (via Nabble) wrote: Does it make any difference if you put the CascadeType.ALL on both sides? Does

Re: Eager fetching of PersistentCollection gives error

2009-04-02 Thread Paul Copeland
Hi Ted - Just to clarify, have you tried this with FetchType.EAGER and with no FetchType specified and in those cases the problem does not happen? A more general observation is that the semantics of this OpenJPA @PersistentCollection extension do not seem to be fully specified (is there a

Re: Eager fetching of PersistentCollection gives error

2009-04-02 Thread Paul Copeland
generally suffice for catching modifications. On Thu, Apr 02, 2009 at 07:26:38AM -0700, Paul Copeland wrote: Hi Ted - Just to clarify, have you tried this with FetchType.EAGER and with no FetchType specified and in those cases the problem does not happen? A more general observation

Determining if Lazily fetched Collection is loaded

2009-04-02 Thread Paul Copeland
Is there a way to tell if a lazily fetched Collection is already loaded without accessing the field and forcing it to load? I want to add a new persistent entity to a Collection, but only if the Collection has already been fetched - because fetching a large collection may be expensive. But

Re: Inconsistent behaviour with Bi-directional One to Many Mapping.

2009-04-01 Thread Paul Copeland
Does it make any difference if you put the CascadeType.ALL on both sides? Does it make any difference if you put optional=false on the ManyToOne ? @ManyToOne (optional=false, CascadeType.ALL) On 4/1/2009 10:29 AM, srini.krish wrote: Hi , I am trying to create a bidirectional one to many

Re: how to store collection of enums as strings

2009-03-30 Thread Paul Copeland
a very straight forward use case though so I'm surprised no one has asked or done anything about this before. On Sat, Mar 28, 2009 at 10:13:16PM -0700, Paul Copeland wrote: What is your objective? Do you want some non-JPA application to see them in the database as Strings

Best practice for LAZY OneToMany

2009-03-28 Thread Paul Copeland
Here is a naive question about a OneToMany relationship. This is probably a basic question. I have a lazily fetched List. It might be large and I don't want to load it until it is accessed. In a transaction - If I create and persist a new Entity that is a member of the list, I think (is

Re: how to store collection of enums as strings

2009-03-28 Thread Paul Copeland
Hi - This is from the OpenJPA relations example - @Basic @Enumerated(EnumType.STRING) private Gender gender; public static enum Gender { MALE, FEMALE } public void setGender(Gender gender) { this.gender = gender; } See section 12.8.1.2 in the OpenJPA Overview - Paul On

Re: Best practice for LAZY OneToMany

2009-03-28 Thread Paul Copeland
it belongs to. This persist action should not load its master's members list. Catalina On Sat, Mar 28, 2009 at 12:06 PM, Paul Copeland t...@jotobjects.com wrote: Here is a naive question about a OneToMany relationship. This is probably a basic question. I have a lazily fetched List. It might

Re: Best practice for LAZY OneToMany

2009-03-28 Thread Paul Copeland
not force the lazily fetched fields to be loaded. What is the behavior? - Paul On 3/28/2009 2:25 PM, Paul Copeland wrote: Hi Catalina - All of what you said confirms my understanding. One question I have is will a new Persistent member that has not been flushed in the same transaction be returned

Re: Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

2009-03-28 Thread Paul Copeland
Your alternatives depend on the database you are using. What database? On 3/28/2009 6:24 PM, 乔木 wrote: I don't want openjpa to create that table

Re: how to store collection of enums as strings

2009-03-28 Thread Paul Copeland
value both for table generation and storage value. On Sat, Mar 28, 2009 at 01:56:13PM -0700, Paul Copeland wrote: Hi - This is from the OpenJPA relations example - @Basic @Enumerated(EnumType.STRING) private Gender gender; public static enum Gender { MALE, FEMALE } public void

Re: Questions about classpath for OpenJPA

2009-03-26 Thread Paul Copeland
app and I'll take a look at it. brbr-Rick brblockquote class=quote light-black dark-border-colordiv class=quote light-border-color div class=quote-author style=font-weight: bold;Paul Copeland wrote:/div div class=quote-message shrinkable-quoteHi Rick - brbrThanks. As I mentioned the openjpa

Re: how to count sub-elements without retrieving them?

2009-03-25 Thread Paul Copeland
Hi Edoardo - This is a bit off the topic of your question, but I am interested in your pattern for setting the EntityManager in a filter. That seems like a reasonable thing to do. I wonder if other servlet developers on the list do it any other way? One question I have for you is that

Re: [ANNOUNCE] OpenJPA 1.2.1 released

2009-03-24 Thread Paul Copeland
Mike - Thanks for all the great work on this. The link below is for the older 1.2.0 release. Here is the link for the NEW 1.2.1 release notes - http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/RELEASE-NOTES.html On 3/23/2009 6:10 PM, Michael Dick wrote: OpenJPA 1.2.1 is now

Re: [ANNOUNCE] OpenJPA 1.2.1 released

2009-03-24 Thread Paul Copeland
On Tue, Mar 24, 2009 at 10:00 AM, Paul Copeland t...@jotobjects.com wrote: Mike - Thanks for all the great work on this. The link below is for the older 1.2.0 release. Here is the link for the NEW 1.2.1 release notes - http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/RELEASE

Re: Questions about classpath for OpenJPA

2009-03-23 Thread Paul Copeland
specific to your environment.? I was able to run the examples on my box without adding xercesImpl.jar to my classpath. With my JSE1.6 install, SAXParserFactoryImpl is found in the [java_home]\lib\rt.jar. -Rick Paul Copeland wrote: More info on this. I upgraded to Java SE 1.6.0_12 and I still need

Re: Questions about classpath for OpenJPA

2009-03-23 Thread Paul Copeland
correction to prior message - my very simple test app does not work without xerces. On 3/23/2009 10:25 AM, Paul Copeland wrote: Hi Rick - Thanks. As I mentioned the openjpa example hellojpa also works for me WITHOUT the xerces jar. But my very simple test app does not work with xerces

Re: Questions about classpath for OpenJPA

2009-03-21 Thread Paul Copeland
with earlier versions, I just grabbed the latest from the maven repository). -mike On Fri, Mar 20, 2009 at 10:26 AM, Paul Copeland t...@jotobjects.com wrote: Interesting. Does this Jira bug say that OpenJPA applications can compile and run with Java 1.6 as long as they do not use JDBC 4

Re: Slow performance with OpenJPA when selecting from a ManyToMany relation.

2009-03-21 Thread Paul Copeland
it on the others (too many lines to highlight accurately. I'm still looking, but thought this was worth sharing in case someone else sees something I've missed. -mike On Thu, Mar 19, 2009 at 10:53 AM, Paul Copeland t...@jotobjects.com wrote: At one point in this thread it was mentioned

Re: Slow performance with OpenJPA when selecting from a ManyToMany relation.

2009-03-21 Thread Paul Copeland
highlighted the changed lines in WarehouseDAO, but missed it on the others (too many lines to highlight accurately. I'm still looking, but thought this was worth sharing in case someone else sees something I've missed. -mike On Thu, Mar 19, 2009 at 10:53 AM, Paul Copeland t...@jotobjects.comwrote

Re: Postgres supported versions

2009-03-20 Thread Paul Copeland
=jdbc:postgresql://localhost:5432/myDBname/ property name=openjpa.ConnectionUserName value=x/ property name=openjpa.ConnectionPassword value=xx/ !-- END PROPERTIES FOR OpenJPA -- Judes On Tue, Mar 17, 2009 at 9:27 AM, Paul Copeland t...@jotobjects.com wrote: Thanks

Re: NullPointerException?

2009-03-19 Thread Paul Copeland
Which version of OpenJPA are you using? On 3/19/2009 4:06 AM, d...@sparnord.dk wrote: Hi, I'm getting this exception: org.apache.openjpa.persistence.PersistenceException: null at org.apache.openjpa.jdbc.meta.FieldMapping.assertStrategy(FieldMapping.java:888)

Re: Questions about classpath for OpenJPA

2009-03-19 Thread Paul Copeland
#a1449832 [2] http://www.onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html [3] http://webspherepersistence.blogspot.com/2009/01/jpa-connection-pooling.html hth, -Jeremy On Thu, Mar 19, 2009 at 2:33 PM, Paul Copeland t...@jotobjects.com wrote: I am just getting

Re: Postgres supported versions

2009-03-17 Thread Paul Copeland
for Postgres 8.2x and 8.3x since the openJPA manual only mentions support for Postgres 8.1.5. Is there a sure way to answer that question? - Paul | On 3/16/2009 7:07 PM, Judes Tumuhairwe wrote: I'm using Postgres 8.2 with no problems. Judes On Mon, Mar 16, 2009 at 5:16 PM, Paul Copeland t

Re: Slow performance with OpenJPA when selecting from a ManyToMany relation.

2009-03-17 Thread Paul Copeland
What is different abut your laptop at home vs. multiple computers at work? Are they all connected to the same network? On 3/17/2009 11:30 AM, Shubbis wrote: Ok, I still dont know what the problem is, but it seems like its not OpenJPA's fault (i think). I just took the whole project home with

Re: How do I persist timestamp in UTC timezone?

2009-03-17 Thread Paul Copeland
Of course java.util.Date is already measured in milliseconds UTC without regard to TimeZone. So it may seem that you are converting your Date objects to a different timezone, but that's not the case. This is why you can use Calendar.compareTo() with objects in different TimeZones. By

Re: How do I persist timestamp in UTC timezone?

2009-03-17 Thread Paul Copeland
time zone, the timestamp value in the database is 2009-03-17-16.23.27.494000. Let me try a simple POJO test case to see if this is an openjpa problem or not. --- On Tue, 3/17/09, Paul Copeland t...@jotobjects.com wrote: From: Paul Copeland t...@jotobjects.com Subject: Re: How do I

Postgres supported versions

2009-03-16 Thread Paul Copeland
I would like to use Postgres 8.2 (latest 8.2 minor version is 8.2.13). The openJPA manual lists Postgres 8.1.5 as a supported database in Appendix 2. The openJPA reference guide section 4 Database Support says OpenJPA can take advantage of any JDBC 2.x compliant driver and then points to the