openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject NPE loading fields of one-to-many collection
Date Mon, 14 Dec 2009 20:44:33 GMT
Using OpenJPA 1.2.1, presently with neither load-time or build-time
enhancement, for different reasons.  I have a ticket open for my
build-time enhancement issues.  It could be that since OpenJPA doesn't
support running without enhancement, I won't be able to make any
significant progress on this until my issues with build-time enhancement
are resolved.

I have mapped two simple classes, and I'm now trying to test the
mappings.  Each class has one relationship attribute.  The first one
relates to the second one, and the second one has a recursive
relationship.  Each one of these relationships is done with a join
table.  I believe I've specified the correct annotations and orm.xml
settings to do this mapping.  I tried running the generated SQL I saw
for the relationship, and it appears to give me a reasonable result.

I think the first relationship is working fine, but the second one is
giving me trouble.  When I run a request where the second relationship
ends up being empty, it works fine.  If it's not empty, I see the
following unhelpful message:

  WARNING: WebApplicationException has been caught : cause is

There is no stack trace.  So, I set Eclipse to stop on NPE and I found
it stopping at the following place:

t) line: not available	
	StateManagerImpl.replaceField(PersistenceCapable, FieldManager,
int) line: 3025	
	StateManagerImpl.storeObjectField(int, Object) line: 2457	
	StateManagerImpl.storeObject(int, Object) line: 2447	
OpenJPAStateManager, JDBCStore, JDBCFetchConfiguration) line: 569	
	FieldMapping.load(OpenJPAStateManager, JDBCStore,
JDBCFetchConfiguration) line: 819	
	JDBCStoreManager.load(OpenJPAStateManager, BitSet,
FetchConfiguration, int, Object) line: 688	
BitSet, FetchConfiguration, int, Object) line: 116	
	ROPStoreManager.load(OpenJPAStateManager, BitSet,
FetchConfiguration, int, Object) line: 78	
	StateManagerImpl.loadFields(BitSet, FetchConfiguration, int,
Object) line: 2921	
	StateManagerImpl.loadField(int, int, boolean, boolean) line:
	StateManagerImpl.fetchObjectField(int) line: 2242	
	StateManagerImpl.fetchField(int, boolean) line: 778	
	StateManagerImpl.fetch(int) line: 740	
	RedefinitionHelper$1.invoke(Object, Method, Object[]) line: 230	
	$Proxy130.iterator() line: not available	

The fields of the class in question are:

    private String  id;
    private String  displayName;
    private Date    creationDate;
    @OneToMany(fetch = FetchType.EAGER)
    private Set<Category>   childCategories;

The relevant portion of the orm.xml file is this:

   <entity name="Category" class="...domain.Category">
        <table name="CATEGORY"/>
            <id name="id">
                <column name="CATEGORY_ID"/>
            <one-to-many name="childCategories"
                <join-table name="CAT_CHLDCAT">
                    <join-column name="CATEGORY_ID"
                    <inverse-join-column name="CHILD_CAT_ID"

View raw message