Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping a class as component with array type field

 
M. Saeed
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three classes A, B, C as shown below. A has a field of type B, and B has a field of type array of C, called "cArray". B is mapped as an hibernate "component".

The component mapping for class B causes a NullPointerException in internal hibernate code, if either any value in cArray is null, or if cArray itself is null. If B is made an entity mapping, then there are no exceptions. (although B shouldn't be an entity).

The java code itself was written sometime ago, so it can't be changed.

My questions are
1) Is there anything wrong with the component mapping of B?
2) Does hibernate component mapping not allow null values in array fields of components, and the array field itself can't be null?

Appreciate any responses.



Exception:



Java classes



Simplified test code:


Hibernate Mappings:
Mapping for class A:




Mapping for Class C



Database Schema:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic