i have an entity which resolves a n:m relation whichs name is Category_Performance
Category <-> Category_Performance is uni directional (category_performance has an instance of category)
Performance <-> Category_Performance is bi-directional (category_performance has an instance of performance and performance has a set of category_performance)
now, there is yet another relationship between a third entity and category_performance, which didnt work so i replaced it with a much simpler entity i called TestEntity
now this adds another relation
Category_Performance <-> TestEntity which is bi-directional again (category_performance has a set of testentity and testentity has an instance of category_performance)
(ill post the mapping files of category_performance and testentity below)
the problem is the following:
i have an instance of Category_Performance in my code which has a method to get the set of TestEntity
i debuuged around a lot and when i call getTests(), hibernate automatically calls setTests() and passes the Category_Performance a set
when i check the set for != null it turns out that the set hibernate passes is not null, however when i attempt to use the set i get nullpointerexceptions
no matter what i do with the set, be it calling .toString(), .add() etc - it always throws a null pointer exception but the set is not null (yey great..)
if i make a new TestEntity and set its Category_Performance to some Category_Performance instance and add that Test_Entity into the database it adds the thing correctly without problems
and then if i close the program, open it again and search the Category_Performance (the one which the TestEntity references) which then actually should contain the previously reference TestEntity in its set - nullpointerexception
so it seems the whole problem seems to be within Category_Performance and i have absolutely no freaking idea why, the sets are exactly the same as in all the other entities and i really dont know if the fact that Category_Performance is an entity resolving a n:m relation can influence the sets it holds?
the mapping file for category_performance looks like this
Code:
//Mapping for Category_Performance
<hibernate-mapping>
<class name="ticketLine.database.entity.Category_Performance" table="Category_Performance">
<meta attribute="extra-import">ticketLine.database.entity.Entity</meta>
<meta attribute="extends">Entity</meta>
<composite-id name="key" class="ticketLine.database.entity.Category_PerformanceKey" unsaved-value="any">
<key-property name="Category_Hall_name" type="java.lang.String" length="20"/>
<key-property name="Category_Hall_Location_Address_addressId" type="java.lang.Integer"/>
<key-property name="Category_Hall_Location_name" type="java.lang.String" length="45"/>
<key-property name="Category_name" type="java.lang.String" length="20" />
<key-property name="Performance_beginTimestamp" type="java.sql.Timestamp"/>
<key-property name="Performance_Event_name" type="java.lang.String" length="45"/>
<key-property name="Performance_Event_category" type="java.lang.String" length="20"/>
</composite-id>
<property name="price" type="java.lang.Double" not-null="true" />
<many-to-one name="performance" class="ticketLine.database.entity.Performance"
insert="false" update="false">
<column name="Performance_beginTimestamp"/>
<column name="Performance_Event_name"/>
<column name="Performance_Event_category"/>
</many-to-one>
<many-to-one name="category" class="ticketLine.database.entity.Category"
insert="false" update="false">
<column name="Category_Hall_name"/>
<column name="Category_Hall_Location_Address_addressId"/>
<column name="Category_Hall_Location_name"/>
<column name="Category_name"/>
</many-to-one>
<set name="tests" table="TestEntity">
<key>
<column name="Category_Performance_Category_Hall_name"/>
<column name="Category_Performance_Category_Hall_Location_Address_addressId"/>
<column name="Category_Performance_Category_Hall_Location_name"/>
<column name="Category_Performance_Category_name"/>
<column name="Category_Performance_Performance_beginTimestamp"/>
<column name="Category_Performance_Performance_Event_name"/>
<column name="Category_Performance_Performance_Event_category"/>
</key>
<one-to-many class="ticketLine.database.entity.TestEntity"/>
</set>
</class>
</hibernate-mapping>
the mapping file for TestEntity looks like this
Code:
//Mapping for Category_Performance
<hibernate-mapping package="ticketLine.database.entity">
<class name="TestEntity" table="TestEntity">
<composite-id name="key" class="ticketLine.database.entity.TestKey" unsaved-value="any">
<key-property name="testId" column="testId" type="java.lang.Integer" />
</composite-id>
<property name="Category_Performance_Performance_beginTimestamp" type="java.sql.Timestamp" not-null="true"/>
<property name="Category_Performance_Performance_Event_name" type="java.lang.String" not-null="true" length="45"/>
<property name="Category_Performance_Performance_Event_category" type="java.lang.String" not-null="true" length="20"/>
<property name="Category_Performance_Category_Hall_name" type="java.lang.String" not-null="true" length="20"/>
<property name="Category_Performance_Category_Hall_Location_Address_addressId" type="java.lang.Integer" not-null="true"/>
<property name="Category_Performance_Category_Hall_Location_name" type="java.lang.String" not-null="true" length="45"/>
<property name="Category_Performance_Category_name" type="java.lang.String" not-null="true" length="20"/>
<many-to-one name="Category_Performance" class="ticketLine.database.entity.Category_Performance"
insert="false" update="false">
<column name="Category_Performance_Category_Hall_name"/>
<column name="Category_Performance_Category_Hall_Location_Address_addressId"/>
<column name="Category_Performance_Category_Hall_Location_name"/>
<column name="Category_Performance_Category_name"/>
<column name="Category_Performance_Performance_beginTimestamp"/>
<column name="Category_Performance_Performance_Event_name"/>
<column name="Category_Performance_Performance_Event_category"/>
</many-to-one>
<property name="value" type="java.lang.Integer" not-null="true" />
</class>
</hibernate-mapping>
[/code]