Hibernates return null for map value object if all persistant properties of the object are set to null.
So, because of this I have a problem.
I have main object with map property. In hibernate mapping, the values of the map are composite elements.
When i instantiate new composite object without setting any of it's properties (they all have null value), and put the composite element in the map, then save main object I get new record in the composite element's database table with relation to main object set correctly, and the map key is also there. all composite element's properties are null as they should be since I did'n asign any values to them. Now, when I load main object from the database in another transaction, I have null value for entire composite element in map, not just it's properties.
I suppose this is the way for hibernate to distinct null values from the values which are not null. (if all values are null then the object is null), but I find that wrong. Why doesn't Hibernate add extra column in the composite elements table called something like "isNull" and use it for detecting null values instead of trying to conclude it from properties?
|