-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Nullpointer exception when binding a type (SortedMap)
PostPosted: Tue Jun 19, 2007 3:38 am 
Newbie

Joined: Tue Jun 19, 2007 2:44 am
Posts: 2
Hibernate version:
3.2.4.sp1

Mapping documents:
@CollectionOfElements
@JoinTable(name="user_play_history", schema="service_users_tracking",
joinColumns = @JoinColumn(name="user_id"))
@MapKey(columns = {@Column(name="time")})
@Column(name = "track_id")
@Type(type="integer")
@Sort(type=SortType.NATURAL)
private SortedMap<Date,Integer> trackHistory = new TreeMap<Date,Integer>();

Full stack trace of any exception that occurs:

java.lang.NullPointerException
at org.hibernate.cfg.annotations.MapBinder.bindKeyFromAssociationTable(MapBinder.java:129)
at org.hibernate.cfg.annotations.MapBinder.access$000(MapBinder.java:53)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:83)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at com.philips.xstream.database.entity.user.impl.TestUserDao.setUp(TestUserDao.java:30)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Name and version of the database you are using:
Mysql 5.0.27

The generated SQL (show_sql=true):
09:33:33,500 DEBUG CollectionSecondPass:57 - Mapped collection key: user_event_id, index: map_key, element: map_value
09:33:33,500 DEBUG CollectionSecondPass:41 - Second pass for collection: user.impl.UserImpl.trackHistory
09:33:33,500 DEBUG CollectionBinder:1026 - Binding a collection of element: user.impl.UserImpl.trackHistory
09:33:33,500 DEBUG SimpleValueBinder:220 - building SimpleValue for null

Debug level Hibernate log excerpt:

I need some help with this please.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 9:16 am 
Newbie

Joined: Fri Mar 07, 2008 8:56 am
Posts: 1
hibernate: 3.2.5.ga
hibernate-annotations: 3.3.0.ga

I'm having exactly the same issue.

Browsing a bit the source code, i realized that the NullPointerException is being raised beacause the following method returns null in org.hibernate.annotations.common.reflection.java.JavaXCollectionType:

Code:
public XClass getMapKey() {
   return new TypeSwitch<XClass>() {
      @Override
      public XClass caseParameterizedType(ParameterizedType parameterizedType) {
         if ( getCollectionClass().isAssignableFrom( Map.class ) ) {
            return toXClass( parameterizedType.getActualTypeArguments()[0] );
         }
         return null;
      }
   }.doSwitch( approximate() );
}


More specifically, the following expression seems misconstructed to me:

Code:
getCollectionClass().isAssignableFrom( Map.class )


The correct expression would be, imho:

Code:
Map.class.isAssignableFrom( getCollectionClass() )


I couldn't find any similar bug in Hibernate JIRA. Should I fire a bug for this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.