Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328749 - A false boolean value is not populated into an EObject when using the Hibernate merge() API
Summary: A false boolean value is not populated into an EObject when using the Hiberna...
Status: ASSIGNED
Alias: None
Product: EMF
Classification: Modeling
Component: Teneo (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Taal CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-26 13:45 EDT by Nikita CLA
Modified: 2010-10-29 08:31 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita CLA 2010-10-26 13:45:48 EDT
Build Identifier: org.eclipse.emf.teneo-1.1.2-v201007191154

I have an EClass which has a boolean field. Using the session.merge() method, I persist a value for which the boolean field is set to false. In the EObject returned by the merge() method, the boolean field is set to null.

I think this happens because of the following:
 * In org.eclipse.emf.teneo.hibernate.mapping.property.EAttributePropertyHandler, in the set() method, Teneo first retrieves the current value of the field that's about to be set.
 * If the current value is the same as the new value that came back from the DB, Teneo skips setting the field.
 * The problem is that, for a boolean field, retrieving the current value gives the value false, even when the actual field value is null. This is because there is logic in org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.InternalSettingDelegateSingleData (line 1962) which says if the value of the field is null, return the defaultValue (which for boolean is false).

Reproducible: Always

Steps to Reproduce:
1. Define an EClass that has a boolean field (xsd:boolean when generating Ecore from XSD).
2. Using the merge() API, persist an instance of the type that has a false boolean value. The value is written to the DB, but the EObject returned by the merge() call will have the value null in the boolean field.
Comment 1 Nikita CLA 2010-10-26 13:49:04 EDT
I added a test case in Assembla (r74).
Comment 2 Martin Taal CLA 2010-10-29 08:31:09 EDT
Hi,
A solution for non-eav cases has been committed to cvs and will be in the next build. 

Another issue I found is that merge does not work for EAV, I will send a separate email on this.
Note that EMF default value handling is a bit specific (as you noted), see this lengthy discussion thread on the topic:
http://www.eclipse.org/forums/index.php?t=tree&th=161533&

gr. Martin