Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » isLoaded NullPointerException
isLoaded NullPointerException [message #1203454] Fri, 22 November 2013 12:18
Dragan Bobic is currently offline Dragan Bobic
Messages: 1
Registered: November 2013
Junior Member
Why the java.lang.NullPointerException exception occurs during Persistence.getPersistenceUtil().isLoaded(entityA, "list") method execution for multitenant entities?
@Entity
@Table(name = "entity_a")
@Multitenant(MultitenantType.TABLE_PER_TENANT)
@TenantTableDiscriminator(type= TenantTableDiscriminatorType.SCHEMA)
public class EntityA implements Serializable {

    @OneToMany(cascade = CascadeType.ALL, 
            mappedBy = "ea",
            fetch = FetchType.LAZY)
    private List<EntityB> list= new ArrayList<EntityB>();
...

@Entity
@Table(name = "entity_b")
@Multitenant(MultitenantType.TABLE_PER_TENANT)
@TenantTableDiscriminator(type= TenantTableDiscriminatorType.SCHEMA)
public class EntityB implements Serializable {
...
@JoinColumns({...})
    @ManyToOne
    private EntityA ea;
...

//Main
EntityManager em = Persistence.createEntityManagerFactory("PersistenceUnit")
                .createEntityManager();
        em.getTransaction().begin();
        em.setProperty(
                EntityManagerProperties.MULTITENANT_PROPERTY_DEFAULT,
                "schema"
        );
	EntityA entityA = em.find(EntityA.class, "1");
        Persistence.getPersistenceUtil().isLoaded(entityA, "list");
        em.getTransaction().commit();

Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-69] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException was thrown while extracting a value from the instance variable [list] in the object [jpatest.EntityA].
Internal Exception: java.lang.NullPointerException
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[otherTaxableIncomeItemList]
Descriptor: RelationalDescriptor(jpatest.EntityA --> [DatabaseTable(entity_a)])
	at org.eclipse.persistence.exceptions.DescriptorException.nullPointerWhileGettingValueThruInstanceVariableAccessor(DescriptorException.java:1275)
	at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor.getAttributeValueFromObject(InstanceVariableAttributeAccessor.java:88)
	at org.eclipse.persistence.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:579)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.getAttributeValueFromObject(ForeignReferenceMapping.java:974)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.isLoaded(EntityManagerFactoryImpl.java:172)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.isLoaded(EntityManagerFactoryImpl.java:153)
	at org.eclipse.persistence.jpa.PersistenceProvider.isLoadedWithReference(PersistenceProvider.java:439)
	at javax.persistence.Persistence$1.isLoaded(Persistence.java:83)
	at jpatest.JPATest.main(JPATest.java:45)
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor.getAttributeValueFromObject(InstanceVariableAttributeAccessor.java:76)
	... 7 more
Java Result: 1



Thank you, Dragan.

[Updated on: Sun, 24 November 2013 03:22]

Report message to a moderator

Previous Topic:Context-sensitive composite primary keys
Next Topic:Schema per Tenant issues
Goto Forum:
  


Current Time: Sat Aug 23 05:37:15 EDT 2014

Powered by FUDForum. Page generated in 0.01658 seconds