Tim - Can you post your Entity and the full exception stack?
Thanks, Rick On Thu, May 12, 2011 at 3:14 AM, tfriess <[email protected]> wrote: > Hello, > I have a problem in persisting/ retrieving an entity containing a > List<String> as field using OpenJPA Version 1.2.2. (I have to use OpenJPA > 1.x and can not use OpenJPA 2.x). > I have searched in the archive of this mailing list and the web but didn't > found a solution for me. In general @PersistentCollection seems to work > here, but I still have problems: > > I tried both ways for the configuration: Using Annotations in the entity > class or an orm.xml - it didn't change anything. > Using the orm.xml I marked this field with the <basic .../> tag, with > Annotations I used @PersistentCollection. > > Persisting such an entity works fine, for both configuration ways OpenJPA > creates an additional table in the database that hold the lists values; if > an entity with such an list is persisted, I can see the data stored > correctly in the database (using a client tool to access the DB directly). > > The problem arises when I try to fetch such objects out of the database > using a Query. (It seems to work sometimes for the PersistentManager.find > method when you know the PK for an object). When I execute a query > Query q = em.createQuery("SELECT myt FROM MYTABLE myt"); > and then call q.getResultList() > I get an exception > Exception in thread "main" <openjpa-1.2.2-r422266:898935 nonfatal general > error> org.apache.openjpa.persistence.PersistenceException: > java.lang.String > incompatible with org.apache.openjpa.enhance.PersistenceCapable > [...] > Caused by: java.lang.ClassCastException: java.lang.String incompatible with > org.apache.openjpa.enhance.PersistenceCapable > > I observed that I can query for such entities without any problem when > there > are no values for the List<String> field of the entity (when the list is > empty), but as soon as I add some values to it and persist such an entity, > I > get this problem. > > I would appreciate any help, > thank you very much! > > Kind regards, > Tim >
