[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4947?page=c...
]
Andreas Deppisch commented on HHH-4947:
---------------------------------------
I know this kind of issue was discussed a lot. But from my point of view I agree that this
is a bug. I read the arguments from Gavin from issue HHH-772, but I disagree with him. My
use case is a map with key value pairs whereas the total map is an identifier. For that
use case a map with a key and value {{null}} is different to a map with a removed key. A
comparison from a map written to the database and reading the same map fails always.
Not expecting this issue, now it is a big effort to change my datamodel and rework the
mapping in order to get what I need because the software is already running on several
customer projects.
Please Gavin rethink your arguments. Maybe there is a compromise to set the behaviour with
annotations as already suggested.
Silent exclusion of null-valued map entry
-----------------------------------------
Key: HHH-4947
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4947
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2, 3.5.0-CR-1
Reporter: Tsering Shrestha
<class name="Product">
<id name="id">
<generator class="native"/>
</id>
<map name="sellingPrice">
<key column="PRODUCT" not-null="true"
foreign-key="FK_SP_PRODUCT"/>
<map-key type="string" column="model"
not-null="true"/>
<element type="double" column="price"
not-null="false"/>
</map>
</class>
Product product = new Product();
Product.getSellingPrice().put("XL",null);
Product.getSellingPrice().put("L", 34.90);
session.save(product)
Gives the following SQL:
insert into PRODUCT (id) values (null)
call identity()
insert into SELLINGPRICE (PRODUCT, MODEL, PRICE) values (?, ?, ?)
And the SELLINGPRICE table indeed only has one row. Why does Hibernately *silently*
remove my null-valued entry? I would either want it to be able to save the entry or raise
an exception that it cannot.
Report this post
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira