Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] project.xml and JPA annotations

You can assign a CMP3Policy using the following code in your
SessionCustomizer,

        Project project = session.getProject();
        for (Iterator iterator =
project.getDescriptors().values().iterator(); iterator.hasNext();){
            ClassDescriptor descriptor = (ClassDescriptor)iterator.next();            
            if (descriptor.getCMPPolicy() == null) {
                descriptor.setCMPPolicy(new CMP3Policy());
            }
        }

EclipseLink does assign this to all descriptors during JPA deployment,
however the customizers are the last thing to run during deployment, so any
descriptors added need to have this set.  EclipseLink could probably do this
check after the customizers run, so feel free to log a bug for that.



fcalfo wrote:
> 
> Thanks - I think I'm getting close - I setup the SessionCustomizer to add
> the descriptors from the Workbench project but when I try to use the
> EntityManager find method to read an object that was mapped in the
> Workbench project, I get a NullPointerException: 
> 
> java.lang.NullPointerException
> 	at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.findInternal(EntityManagerImpl.java:477)
> 	at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:428)
> 	at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:336)
> 
> 
> Somehow, the cmpPolicy is being set automatically for the JPA annotated
> classes to: org.eclipse.persistence.internal.jpa.CMP3Policy
> 
> but it is null on the descriptor from the Workbench project.
> 
> Is there something else I have to define in the Workbench Project or
> persistence defaults etc to get this to work?
> 
> 
> Sebastien Tardif-2 wrote:
>> 
>> Workaround described here:
>> http://forums.oracle.com/forums/thread.jspa?forumID=48&threadID=887041
>> 
>> 
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/project.xml-and-JPA-annotations-tp23262131p23277487.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top