The field is a Set<String> that is stored in a single column so I had
to define an externalizer and a factory for it.

    @PersistentCollection( fetch=FetchType.EAGER,
elementCascade=CascadeType.ALL)
    @Externalizer( "A.tagsToString" )
    @Factory( "A.tagsFromString" )
    @ElementType( String.class )
    @Column( name="tags" )
    private Set<String> tags;

The factory method creates an instance of HashSet<String> so that part
looks ok.  When the value is set for this attribute, if there is only
one value, then a SingletonSet is passed.  Otherwise, a regular
HashSet is used.


Christian

On 9/26/07, Patrick Linskey <[EMAIL PROTECTED]> wrote:
> Hmm. It's really annoying how these new collection types all violate
> the Collection contract as described in the Java 1.2 javadoc. Oh well.
>
> How are you declaring the field? We could probably change OpenJPA to
> at least avoid the error somehow, which should be sufficient since
> SingletonSet is just an optimization.
>
> -Patrick
>
> On 9/25/07, Christian Defoy <[EMAIL PROTECTED]> wrote:
> > Hello!
> >
> > I am getting a strange message when merging an entity.  My entity
> > contains a set of objects of class A.  Each of these objects, in turn,
> > have an attribute that is a set.  My entity gets detached, then a
> > bunch of As get added and every A contains a set.  Most of the As will
> > contain a singleton but still some may contain a regular set.
> >
> > The error message is quite clear.  OpenJPA can't access the superclass
> > because the superclass is private static inside java.util.Collections.
> >
> > java.lang.IllegalAccessError: class
> > org.apache.openjpa.util.java$util$Collections$SingletonSet$0$proxy
> > cannot access its superclass java.util.Collections$SingletonSet
> >         at java.lang.ClassLoader.defineClass1(Native Method)
> >         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> >         at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> >         at serp.bytecode.BCClassLoader.findClass(BCClassLoader.java:73)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> >         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> >         at java.lang.Class.forName0(Native Method)
> >         at java.lang.Class.forName(Class.java:242)
> >         at 
> > org.apache.openjpa.util.ProxyManagerImpl.loadProxy(ProxyManagerImpl.java:479)
> >         at 
> > org.apache.openjpa.util.ProxyManagerImpl.getFactoryProxyCollection(ProxyManagerImpl.java:365)
> >         at 
> > org.apache.openjpa.util.ProxyManagerImpl.copyCollection(ProxyManagerImpl.java:185)
> >         at 
> > org.apache.openjpa.kernel.AttachStrategy.copyCollection(AttachStrategy.java:341)
> >         at 
> > org.apache.openjpa.kernel.AttachStrategy.attachCollection(AttachStrategy.java:318)
> >         at 
> > org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:217)
> >         at 
> > org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:134)
> >         at 
> > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:239)
> >         at 
> > org.apache.openjpa.kernel.AttachStrategy.attachCollection(AttachStrategy.java:330)
> >         at 
> > org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:249)
> >         at 
> > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:239)
> >         at 
> > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:100)
> >         at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3139)
> >         at 
> > org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1147)
> >         at 
> > org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:665)
> >
> >
> > My question is: should I avoid using singleton set?  I guess it is the
> > same kind of issue as with the EnumSet...
> >
> > Thanks in advance!
> >
> > Christian
> >
>
>
> --
> Patrick Linskey
> 202 669 5907
>

Reply via email to