Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Ordered collections: ordered-column causes NPE
icon9.gif  Ordered collections: ordered-column causes NPE [message #1248347] Mon, 17 February 2014 06:47 Go to next message
yuan yao is currently offline yuan yaoFriend
Messages: 6
Registered: February 2014
Junior Member
Any one who use <order-column> with many-to-many or one-to-many associations?

I came with a NPE when I used <order-column>.

<many-to-many name="games" target-entity="GiftGame" attribute-type="java.util.List">
    <order-column name="idx" correction-type="READ_WRITE"></order-column>
    <join-table name="gift_games">
        <join-column name="gift_id" table="gift_games" />
        <inverse-join-column name="game_id" table="gift_games" />
    </join-table>
</many-to-many>


Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [cms] failed.
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
	... 62 more
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.metadata.columns.OrderColumnMetadata.process(OrderColumnMetadata.java:98)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.CollectionAccessor.process(CollectionAccessor.java:670)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToManyAccessor.process(ManyToManyAccessor.java:143)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1578)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1831)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:580)
	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1865)
	... 60 more



I found @OrderedColumn annotation could work. But the cosponding XML element will cause the NPE.



EclipseLink version: 2.5

[Updated on: Mon, 17 February 2014 06:48]

Report message to a moderator

Re: Ordered collections: ordered-column causes NPE [message #1249770 is a reply to message #1248347] Tue, 18 February 2014 15:55 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
The JPA specification defines an @OrderColumn if that is what you are refering to:
http://docs.oracle.com/javaee/6/api/javax/persistence/OrderColumn.html
The XML equivalent would be <order-column name="idx"/> as shown here:
https://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/OrderColumns

Try removing the correction-type which isn't defined in JPA.
Re: Ordered collections: ordered-column causes NPE [message #1252204 is a reply to message #1249770] Fri, 21 February 2014 02:09 Go to previous messageGo to next message
yuan yao is currently offline yuan yaoFriend
Messages: 6
Registered: February 2014
Junior Member
Thanks for your reply.

@OrderColumn works well.

NPE still occurs after removing the 'correction-type'.
Changing many-to-many to one-to-many doesn't solve the problem.


The wiki' demo doesn't use the join table. But here I must use it for many-to-many.

No one ever uses many-to-many && join table && order-column successfully?
Re: Ordered collections: ordered-column causes NPE [message #1266572 is a reply to message #1252204] Fri, 07 March 2014 17:00 Go to previous messageGo to next message
Clovis Wichoski is currently offline Clovis WichoskiFriend
Messages: 7
Registered: March 2012
Junior Member
Hi Yuan,

Have you tried that with version 2.5.1? Can you download the sources of your EclipseLink version and check what are the nearby instrucions of code that causes the NPE? I post a issue here where I found some problem with multi-threads environment, maybe your problem can occurs with multi-threads too.

best regards

Clóvis
Re: Ordered collections: ordered-column causes NPE [message #1269578 is a reply to message #1266572] Wed, 12 March 2014 02:04 Go to previous message
yuan yao is currently offline yuan yaoFriend
Messages: 6
Registered: February 2014
Junior Member
2.5.1 not work either. The same exception is thrown.

The line that throws exceptions:
org.eclipse.persistence.internal.jpa.metadata.columns.OrderColumnMetadata.process(OrderColumnMetadata.java:98)
if (((MetadataAnnotatedElement) getAccessibleObject()).getRawClass(descriptor).isList()) {


I debug it and found '((MetadataAnnotatedElement) getAccessibleObject()).getRawClass(descriptor)' return null.

The following is the flow of getRawClass(). I mark the flow with comments.
org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotatedElement.getRawClass(MetadataDescriptor)
    public MetadataClass getRawClass(MetadataDescriptor descriptor) {
        if (m_rawClass == null) { // Yuan: here
            if (isGenericType()) { // Yuan: here, false
				// ...
            }
            return getMetadataClass(getType()); // Yuan: here, getType() return null!
        }
        
        return m_rawClass;    
    }


1. I feel that the key is 'generic type'. My entities are virtul and not generic typed. So some type info could not be inferred?
2. I use the file orm.xml, not annotations. But why codes run into MetadataAnnotatedElement?

Hope that these fact useful to you.
Previous Topic:Deletion of OneToMany unidirectional mapping does not delete all children
Next Topic:Partitioning and EclipseLink version
Goto Forum:
  


Current Time: Thu Dec 18 18:28:26 GMT 2014

Powered by FUDForum. Page generated in 0.18241 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software