I think I've found a bug in @PersistentCollection(fetch=FetchType.EAGER) 
when used with Strings.  It just doesn't seem to retrieve.

This only happens with FetchType.EAGER and it only happens if the entity 
is being loaded from the database / not cached via openjpa.DataCache. (If 
I create the entity then persist it, then do a find on it, it'll work, I 
think it's because it's just hitting my cache, if I shutdown the jvm, 
then start it up again, then load the entity I see the error.)

The declaration of the column is as follows : 

        @PersistentCollection(fetch=FetchType.EAGER)
        @ContainerTable(name="UserRole", 
joincolum...@xjoincolumn(name="userId", referencedColumnName="id"), 
joinforeignk...@foreignkey)
        @ElementJoinColumn(name="Role")
        private Set<String> roles=new HashSet<String>();

I'm using compile time enhancement.
I'm using java :
        java version "1.6.0_12"
        Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
        Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)

The openjpa is 1.2.1 as retrieved via the apache maven repositories.

The exception is as follows : 
-----------------------------
Caused by: <openjpa-1.2.1-r752877:753278 nonfatal general error> 
org.apache.openjpa.persistence.PersistenceException: java.lang.String 
cannot be cast to org.apache.openjpa.enhance.PersistenceCapable
        at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:875)
        at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:774)
        at 
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:982)
        at 
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
        at 
org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2400)
        at 
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:272)
        at 
org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
        at 
org.apache.openjpa.datacache.QueryCacheStoreQuery$CachingResultObjectProvider.getResultObject(QueryCacheStoreQuery.java:597)
        at 
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
        at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
        at 
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:252)
        at 
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
 
-- 
                                                           Ted Leung
                                                           ted...@sfu.ca

It is easier to speak wisely than to act wisely.

Reply via email to