Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] AttributeGroup, EntityManager.load(...) with Relations to Abstract Superclass

Hi,
    If you have rows that do not have FK relationships set - try a LEFT FETCH JOIN (to get override the LAZY attribute and also to get rows that are not fully populated) as the Root.fetch() defaults to a right join.

	Example
	CriteriaQuery<VigilanceAllergenIngredient> criteriaQuery = getCriteriaBuilder().createQuery(VigilanceAllergenIngredient.class);
       Root<VigilanceAllergenIngredient> root = criteriaQuery.from(VigilanceAllergenIngredient.class);
       if(isEager) {
        	root.fetch(VigilanceAllergenIngredient_.allergenType, JoinType.LEFT);

	/michael
-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of sr_dd
Sent: Sunday, November 11, 2012 12:03 PM
To: eclipselink-users@xxxxxxxxxxx
Subject: Re: [eclipselink-users] AttributeGroup, EntityManager.load(...) with Relations to Abstract Superclass

Hello,

using eclipselink 2.3.3.

i get a Nullpointer in a scenario like this:
Employee LAZY ManyToManyMapping("projects") Project 
HugeProject inherits from Project (HugeProject defines "evangelist") 
SmallProject inherits from Project (SmallProject defines "atheist") 
HugeProject LAZY OneToOneMapping("evangelist") Employee 
SmallProject LAZY OneToOneMapping("aheist") Employee 

// read the Employee 
Employee empRead = em.find(Employee.class, id); 
// create LoadGroup 
LoadGroup lg = new LoadGroup(); 
lg.addAttribute("projects.evangelist"); 
lg.addAttribute("projects.atheist"); 
// load - all SELECT calls executed here 
JpaHelper.getEntityManager(em).load(empRead, lg); 

Depending on the conrete Type the element in Projects has there is a
NullpointerException in AbstractSession Line 4638:
                 while(it.hasNext()) {
                       DatabaseMapping mapping =
builder.getMappingForAttributeName(it.next());
                       // instantiate indirection
                       mapping.instantiateAttribute(object, session);
<--MAPPING is Null
                   }

This is because there is no atheist in HugeProject and no evangelist in
SmallProject Entities.
Another way in creating the LoadGroup for this case?

Best regards
Stefan






--
View this message in context: http://eclipse.1072660.n5.nabble.com/AttributeGroup-EntityManager-load-with-Relations-to-Abstract-Superclass-tp154468p155690.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top