[CDO] Incorrect Management of Null EEnum Objects [message #896290] |
Tue, 17 July 2012 21:40 |
Paco Blanco Messages: 28 Registered: June 2012 |
Junior Member |
|
|
Situation: you have an object that has EEnum Objects as EAttribute childs. When you commit this object with NULL value/values in one/some of the EMF Enum (using CDO), each of them is saved in the database with its enum default value and not with NULL.
I have not the pieces of code that reflect what I say. But when I saw, the problem is in CDO Server Code. CDO Server checks if the enum object is null and, in this case, it calls to EMF getValue. EMF responds with the enum default value and if there is not default value, it takes the first element of the enum value list.
I think that it is not the same a NULL value than a default value (or the first element).
In my DB (DBStore, MySQL), the columns that represent the Enum instances can be null. Logically, if these columns have a not-null constraint, CDO Server can use the EMF getValue method to obtain a not-null value.
[Updated on: Tue, 17 July 2012 21:43] Report message to a moderator
|
|
|
|
Re: [CDO] Incorrect Management of Null EEnum Objects [message #896349 is a reply to message #896331] |
Wed, 18 July 2012 07:06 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
This sounds to me like expected behavior. An EAttribute with a
EEnum type can't take on nor return a null value. I.e., it's
treated like a primitive type. Such a feature will always take on
or return the default value of the type (type first enumerator, must
like int will take on the value 0) or the default value specified
for the feature (i.e., any one of the enumerators). If you
absolutely need null, you must create a wrapping EDataType. E.g.,
as follows in Xcore syntax:<br>
<blockquote>class Book
<br>
{
<br>
BookCategoryObject bookCategory<br>
}<br>
<br>
enum BookCategory
<br>
{
<br>
Mystery as "MYSTERY" = 2
<br>
ScienceFiction as "SiFi" = 1
<br>
Biography as "Bio" = 0
<br>
}
<br>
<br>
@ExtendedMetaData(baseType="BookCategory")
<br>
type BookCategoryObject wraps Enumerator
<br>
</blockquote>
Of if you just need to know if the feature has been explicitly set,
you can make it unsettable to model one additional state; I'm not
sure how CDO preservers that information.<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 18/07/2012 7:20 AM, Eike Stepper
wrote:<br>
</div>
<blockquote cite="mid:ju5h3f$nba$1@xxxxxxxxe.org" type="cite">Am
17.07.2012 23:40, schrieb Paco Blanco:
<br>
<blockquote type="cite">Situation: you have an object that has
EEnum Objects as EAttribute childs. When you commit this object
with NULL value/values in one/some of the EMF Enum (using CDO),
each of them is saved in the database with its enum default
value and not with NULL.
<br>
<br>
I have not the pieces of code that reflect what I say. But when
I saw, the problem is in CDO Server Code. CDO Server checks if
the enum object is null and, in this case, it calls to EMF
getValue. EMF responds with the enum default value and if there
is not default value, it takes the first element of the enum
value list.
<br>
<br>
I think that it is not the same a NULL value than a default
value (or the first element).
<br>
</blockquote>
That sounds like a defect in CDO. Let's see if we can confirm and
fix it. Please submit a bugzilla.
<br>
<br>
Cheers
<br>
/Eike
<br>
<br>
----
<br>
<a class="moz-txt-link-freetext" href="http://www.esc-net.de">http://www.esc-net.de</a>
<br>
<a class="moz-txt-link-freetext" href="http://thegordian.blogspot.com">http://thegordian.blogspot.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://twitter.com/eikestepper">http://twitter.com/eikestepper</a>
<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03483 seconds