Re: Enum as a Key in a Map

2009-08-19 Thread Fay Wang
hi Krzysztof, I have checked the fix into the trunk (r-806011). Please extract the fix, enhance your entities and run the test case again. Please let me know if you still have problem. Regards, Fay - Original Message From: Krzysztof To: users@openjpa.apache.org Sent: Wednes

RE: Encountered unmanaged object

2009-08-19 Thread C N Davies
I hadn't set the child entity as not nullable. My English is pretty poor but I'll see if I can explain the issue more clearly. I have a list of cities that are stored in an excel file, I pull them in and for each one I create a City entity. The addresses get pulled in to my system using Tibco a

Re: Encountered unmanaged object

2009-08-19 Thread Daryl Stultz
On Wed, Aug 19, 2009 at 6:18 PM, C N Davies wrote: > > I have had this issue quite a number of times, it turned out to be a logic > issue in the base class for my in my backing bean that would null out the > child entity in an main entity, when this condition occurs I will always > get > this err

RE: Encountered unmanaged object

2009-08-19 Thread C N Davies
Hi Darryl, Well I am not a JPA expert so I'll answer the bit I can. "How did you end up resolving your problem? I assume the City child is not allowed to be null? I'm not clear how your system got into the state it was in (is it repeatable?)." I have had this issue quite a number of times, it tu

Re: Encountered unmanaged object

2009-08-19 Thread Daryl Stultz
On Wed, Aug 19, 2009 at 4:27 PM, C N Davies wrote: > Hi Daryl, > > I get that exact error if one of my fields in my main entity has a > reference > to a child entity and the child is null. The next line of the error message is something like this: > FailedObject: blah.model.A-1234 I think th

Re: Enum as a Key in a Map

2009-08-19 Thread Krzysztof
Thank you Fay, Probably ApplicationIdTool could be updated as well - it actually creates some code for such cases, but not digestible by the compiler. Best regards, Krzysztof Fay Wang wrote: > > Hi Krzysztof, > This is a generic problem in openjpa. If an entity, say EntityA, has > an IdClas

RE: Encountered unmanaged object

2009-08-19 Thread C N Davies
Hi Daryl, I get that exact error if one of my fields in my main entity has a reference to a child entity and the child is null. For example if I have an Address entity that contains a City entity and for some reason my City entity is null, then when I try to persist the Address entity, I'll get th

Re: Enum as a Key in a Map

2009-08-19 Thread Fay Wang
Hi Krzysztof, This is a generic problem in openjpa. If an entity, say EntityA, has an IdClass which contains an Enum type, and EntityB has a one-to-one relationship with EntityA. This problem will surface during retrieval of EntityA when doing the findBy for EntityB. Apparently there is a bu

Re: Enum as a Key in a Map

2009-08-19 Thread Krzysztof
Thank you, I just tried to add Id class to the enum as a dirty hack but it's not doable of course. Good luck! Krzysztof Fay Wang wrote: > > Hi Krzysztof, > Given your description below, I am able to reproduce this problem. I > will take a look at it. Thanks! > > Regards, > Fay > > > >

Encountered unmanaged object

2009-08-19 Thread Daryl Stultz
Hello, I'm looking for any clues to help troubleshoot the following error: Encountered unmanaged object in persistent field > "blah.model.MyEntity.myPropA" during flush. However, this field does not > allow cascade persist. Set the cascade attribute for this field to > CascadeType.PERSIST or Cas

Re: Enum as a Key in a Map

2009-08-19 Thread Fay Wang
Hi Krzysztof, Given your description below, I am able to reproduce this problem. I will take a look at it. Thanks! Regards, Fay - Original Message From: Krzysztof To: users@openjpa.apache.org Sent: Wednesday, August 19, 2009 11:38:36 AM Subject: Re: Enum as a Key in a Map Tha

Re: Enum as a Key in a Map

2009-08-19 Thread Fay Wang
Hi Krzysztof, I could not reproduce your problem using my own test case. From your annotation, I would suppose that tsType is a persistent field of the map value, and it is of EnumType. Could you provide your domain model for further investigation? Regards, Fay - Original Message -

Re: Enum as a Key in a Map

2009-08-19 Thread Krzysztof
Thanks Kevin, Certainly, I have checked your roadmap and the relevant JIRA issue, also test cases you have in the trunk - have not seen @MapKeyEnumerated used with @OneToMany though. In the Id class of the child I kept enum as a field and used ordinal() obviously. I'm debugging this now and ca

Re: Enum as a Key in a Map

2009-08-19 Thread Kevin Sutter
Hi Krzysztof, The MapKeyEnumerated support was introduced as part of JPA 2.0. It looks like this was committed via OPENJPA-1055. I've pinged Fay (owner of the JIRA) to take a look to see if she has any ideas. If you are interested in what's been done for JPA 2.0 already, you can reference our ro

Re: Enum as a Key in a Map

2009-08-19 Thread Krzysztof
Hello, I'm reviving this as @MapKeyEnumerated has been introduced recently which seemed addressing this issue. Unfortunately, if I use enum as a key where Source is amended with following annotation for the map: @OneToMany(mappedBy = "source",cascade={ CascadeType.ALL },fetch = FetchType

Re: Key and Value limitations in a Map

2009-08-19 Thread Krzysztof
Hello Fay, Yes, I am aware of that and switching to @Entity dragged me to this bug in the end. In the real scenario AbstractModel Id is a DerivedTS field which Id is also AbstractModel etc. I had not been able to run without circular id dependency in first place - hence simplified example I poste

Re: openjpa, derby, pooled connections?

2009-08-19 Thread Kevin Sutter
Rick has also posted information on connection pooling with OpenJPA on this blog entry: http://webspherepersistence.blogspot.com/2009/01/jpa-connection-pooling.html Kevin On Wed, Aug 19, 2009 at 9:29 AM, Michael Dick wrote: > > Hi Chris, > > OpenJPA does not include a connection pool, so you'll

Re: Key and Value limitations in a Map

2009-08-19 Thread Fay Wang
Hi Krzysztof, The exception reported in JIRA-291 is apparently different from the exception that you reported: [java] Caused by: org.apache.openjpa.util.MetaDataException: Field "DerivedTS.parentModel" cannot be a primary key. It is of an unsupported type. [java] at org.apache.openjp

Re: openjpa, derby, pooled connections?

2009-08-19 Thread Michael Dick
Hi Chris, OpenJPA does not include a connection pool, so you'll need to plug in a third party pool like commons-dbcp. We use commons-dbcp fairly extensively in our unit tests and it can be configured similarly to a direct connection to the database. For example to use derby add these properti

Re: Key and Value limitations in a Map

2009-08-19 Thread Krzysztof
Hello Fay, Thank you for the hint. In the end I narrowed down the problem to self-referencing, composite ID which is not supported. Kludging with a generated syntatic Id helps in cases where object model is modifiable but it would be wonderful to have this supported at some time. Do you think