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