Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Incorrect Management of Null EEnum Objects
[CDO] Incorrect Management of Null EEnum Objects [message #896290] Tue, 17 July 2012 21:40 Go to next message
Paco Blanco is currently offline Paco BlancoFriend
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 #896331 is a reply to message #896290] Wed, 18 July 2012 05:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 17.07.2012 23:40, schrieb Paco Blanco:
> 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).
That sounds like a defect in CDO. Let's see if we can confirm and fix it. Please submit a bugzilla.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Incorrect Management of Null EEnum Objects [message #896349 is a reply to message #896331] Wed, 18 July 2012 07:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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/
Re: [CDO] Incorrect Management of Null EEnum Objects [message #896353 is a reply to message #896349] Wed, 18 July 2012 07:27 Go to previous message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
Ed, you are right :'( The getter of an EEnum always returns a non-null value.
Sorry for the discussion.

I will try the wrapping solution.
Previous Topic:[CDO] Best Practices: how to save a CDObject with unsaved references
Next Topic:master-detail scenario
Goto Forum:
  


Current Time: Wed Apr 24 15:29:38 GMT 2024

Powered by FUDForum. Page generated in 0.03483 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top