[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4060) Dates being converted to Timestamps confuse CollectionUpdateAction/PersistentSet
Phillip Henry (JIRA)
noreply at atlassian.com
Thu Feb 18 08:15:47 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4060?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phillip Henry updated HHH-4060:
-------------------------------
Attachment: persistent_sets_2.patch
Actually, my first attempt causes other tests to fail :(
All tests pass with this.
> Dates being converted to Timestamps confuse CollectionUpdateAction/PersistentSet
> --------------------------------------------------------------------------------
>
> Key: HHH-4060
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4060
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Environment: Hibernate Trunk, all databases
> Reporter: Phillip Henry
> Attachments: persistent_sets_2.patch, timestamp_date_bug.zip
>
>
> If an object that has a Set of java.util.Dates is persisted then retrieved, these element become java.sql.Timestamps. This is fine but PersistentSet then treats Sets of Dates and Timetstamps inconsistently.
> Eg, if the collection is cleared, this results in CollectionUpdateAction thinking the elements need to be deleted from the DB (see how PersistentSet.getDeletes uses Set.contains() when comparing Dates and Timestamps - leading to a call to Timestamp.equals which Date fails).
> But if the java.util.Date elements (the same that we started with) are then re-added, CollectionUpdateAction thinks that they are the same as the ones the Set once contained (see how PersistentSet.needsInserting compares the re-added elements with its snapshot - leading to a call to Date.equals which Timestamp passes) and therefore does not think it needs to persist them.
> The result is that no date elements at all are left in the DB by the time the transaction commits.
> I've attached a test that demonstrates the problem.
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list