-->
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.  [ 5 posts ] 
Author Message
 Post subject: Null reference in findall
PostPosted: Fri Feb 15, 2008 5:27 am 
Newbie

Joined: Fri Feb 15, 2008 5:07 am
Posts: 13
Hi, i'm using hibernate 3.1 with spring 2.0 (Spring & Hibernate support from MyEclipse), i can store some objects and query other but i have a relatioship of type many to one with composite id and when i try to query this object a null reference exception is raised, the strange thing is that the query is executed against the database (MySql5).

The xml files are:

Option Role Object
------------------------------------------------------
<class name="sicce.api.info.OptionRole" table="option_role" catalog="sicce">
<composite-id name="id" class="sicce.api.info.OptionRoleId">
<key-many-to-one name="role" class="sicce.api.info.Role">
<column name="ID_ROLE" />
</key-many-to-one>
<key-many-to-one name="optionSicce" class="sicce.api.info.OptionSicce">
<column name="ID_OPTION_SICCE" />
</key-many-to-one>
</composite-id>
</class>
-------------------------------------------------------

The other files are:

Role
-------------------------------------------------------
<class name="sicce.api.info.Role" table="role" catalog="sicce">
<id name="idRole" type="java.lang.Integer">
<column name="ID_ROLE" />
<generator class="increment" />
</id>
<property name="description" type="java.lang.String">
<column name="DESCRIPTION" length="20" />
</property>
<set name="optionRoles" inverse="true" >
<key>
<column name="ID_ROLE" not-null="true" />
</key>
<one-to-many class="sicce.api.info.OptionRole" />
</set>
<set name="userSicces" inverse="true">
<key>
<column name="ID_ROLE" not-null="true" />
</key>
<one-to-many class="sicce.api.info.UserSicce" />
</set>
</class>
-------------------------------------------------------

Option
-------------------------------------------------------
<class name="sicce.api.info.OptionSicce" table="option_sicce" catalog="sicce">
<id name="idOptionSicce" type="java.lang.Integer">
<column name="ID_OPTION_SICCE" />
<generator class="increment" />
</id>
<property name="description" type="java.lang.String">
<column name="DESCRIPTION" length="30" />
</property>
<property name="icon" type="java.lang.String">
<column name="ICON" />
</property>

<set name="optionRoles" inverse="true">
<key>
<column name="ID_OPTION_SICCE" not-null="true" />
</key>
<one-to-many class="sicce.api.info.OptionRole" />
</set>

</class>
--------------------------------------------------------

The exception raised is:

This is the executed query (it return rows if you execute against the db)
-----------------------------------------------------------------------------------
Hibernate: select this_.ID_ROLE as ID1_5_0_, this_.ID_OPTION_SICCE as ID2_5_0_ from sicce.option_role this_ where (1=1)
-----------------------------------------------------------------------------------

Exception
-----------------------------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
.
.
.
-----------------------------------------------------------------------------------

I didn't find any concrete answer for this in the forum or in another page, i generated the files, so what i'm missing in the configuration for this entities because for other entities i can store and retrieve objects without problems.

Regards,

gishac
Db4o Most Valued Professional


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 17, 2008 11:31 pm 
Newbie

Joined: Fri Feb 15, 2008 5:07 am
Posts: 13
Any idea for this problem from someone of the hibernate team??? so bad that nobody answer a question in this forum.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 23, 2008 1:01 pm 
Newbie

Joined: Fri Feb 15, 2008 5:07 am
Posts: 13
well i solved my problem changing the mapping files and avoid using an intermediate class to represent the many-to-many association.

Role mapping

<hibernate-mapping>
<class name="sicce.api.info.Role" table="role" catalog="sicce">
<id name="idRole" type="java.lang.Integer">
<column name="ID_ROLE" />
<generator class="increment" />
</id>
<property name="description" type="java.lang.String">
<column name="DESCRIPTION" length="20" />
</property>

<set name="userSicces" inverse="true">
<key>
<column name="ID_ROLE" not-null="true" />
</key>
<one-to-many class="sicce.api.info.UserSicce" />
</set>

<set name="permissions" table="option_role" lazy="false">
<key>
<column name="ID_ROLE" not-null="true" />
</key>
<many-to-many class="sicce.api.info.OptionSicce" column="ID_OPTION_SICCE" />
</set>


</class>
</hibernate-mapping>


Permissions mapping

<hibernate-mapping>
<class name="sicce.api.info.OptionSicce" table="option_sicce" catalog="sicce">
<id name="idOptionSicce" type="java.lang.Integer">
<column name="ID_OPTION_SICCE" />
<generator class="increment" />
</id>
<property name="description" type="java.lang.String">
<column name="DESCRIPTION" length="30" />
</property>

<property name="icon" type="java.lang.String">
<column name="ICON" />
</property>

<set name="roles" inverse="true" table="option_role" >
<key>
<column name="ID_OPTION_SICCE" not-null="true" />
</key>
<many-to-many class="sicce.api.info.Role" column="ID_ROLE" />
</set>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Same problem
PostPosted: Thu Mar 27, 2008 12:47 pm 
Newbie

Joined: Thu Mar 27, 2008 12:36 pm
Posts: 1
This might be a little late... but I had the same problem with a very similar setup. I would get the same null pointer exception when I went after objects in a one-to-many set (represented by an intermediate class and table). Turns out asm.jar and asm-attrs.jar were not in my classpath. When I added them the error went away!


Top
 Profile  
 
 Post subject: Solved
PostPosted: Thu Mar 27, 2008 10:51 pm 
Newbie

Joined: Fri Feb 15, 2008 5:07 am
Posts: 13
All my mappings work perfectly right now, I just avoid the use of an intermediate class to represent the many-to-many association, and use the xml in my previous post to store the objects.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.