Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Illegal Argument Exception saving null object enumeration
[Teneo] Illegal Argument Exception saving null object enumeration [message #93802] Tue, 21 August 2007 18:05 Go to next message
Jeff Bellegarde is currently offline Jeff BellegardeFriend
Messages: 6
Registered: July 2009
Junior Member
I'm trying to save a model and receiving the following error.


java.lang.IllegalArgumentException: The value 'null' is not a valid
enumerator of 'Period'
at
org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
at
org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
at
org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
at
org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
at
org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at
org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at
org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
at
org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)


The important section of the model is:

<eClassifiers xsi:type="ecore:EClass" name="Exchange">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
unique="false"
eType="#//PeriodObject" unsettable="true"/>
</eClassifiers>

<eClassifiers xsi:type="ecore:EEnum" name="Period">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Period"/>
</eAnnotations>
<eLiterals name="Hour"/>
<eLiterals name="Day" value="1"/>
<eLiterals name="Week" value="2"/>
<eLiterals name="Year" value="3"/>
<eLiterals name="Month" value="4"/>
</eClassifiers>

<eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
instanceClassName="org.eclipse.emf.common.util.Enumerator">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Period:Object"/>
<details key="baseType" value="Period"/>
</eAnnotations>
</eClassifiers>

The indirection through PeriodObject is to allow Exchange.period to be
set to null. Pointing Exchange.period directly to Period saves
correctly, but disallows having a null period.

It looks like Teneo is ignoring the PeriodObject and just dealing with
the Period enum which can not be null.

Is there a way to get Teneo to save a null enum reference correctly?
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #93818 is a reply to message #93802] Tue, 21 August 2007 21:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jeff,
Teneo tries to translate the PeriodObject to a string, to do this it also touches the underlying
Period enum. Afaics you should change the JiemFactoryImpl.createPeriodFromString to handle null
values to solve this.

For my curiosity why does directly using the enum disallow null values?

gr. Martin

Jeff Bellegarde wrote:
> I'm trying to save a model and receiving the following error.
>
>
> java.lang.IllegalArgumentException: The value 'null' is not a valid
> enumerator of 'Period'
> at
> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
>
> at
> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
>
> at
> org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
>
> at
> org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
>
> at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
> at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
> at
> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
> at
> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>
> at
> org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>
> at
> org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
> at
> org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
>
> at
> org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)
>
>
>
> The important section of the model is:
>
> <eClassifiers xsi:type="ecore:EClass" name="Exchange">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
> unique="false"
> eType="#//PeriodObject" unsettable="true"/>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EEnum" name="Period">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Period"/>
> </eAnnotations>
> <eLiterals name="Hour"/>
> <eLiterals name="Day" value="1"/>
> <eLiterals name="Week" value="2"/>
> <eLiterals name="Year" value="3"/>
> <eLiterals name="Month" value="4"/>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
> instanceClassName="org.eclipse.emf.common.util.Enumerator">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Period:Object"/>
> <details key="baseType" value="Period"/>
> </eAnnotations>
> </eClassifiers>
>
> The indirection through PeriodObject is to allow Exchange.period to be
> set to null. Pointing Exchange.period directly to Period saves
> correctly, but disallows having a null period.
>
> It looks like Teneo is ignoring the PeriodObject and just dealing with
> the Period enum which can not be null.
>
> Is there a way to get Teneo to save a null enum reference correctly?
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #93835 is a reply to message #93818] Tue, 21 August 2007 21:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------030906070809010207010804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

The generated code does this

public BookCategory createBookCategoryFromString(EDataType
eDataType, String initialValue)
{
BookCategory result = BookCategory.get(initialValue);
if (result == null) throw new IllegalArgumentException("The
value '" + initialValue + "' is not a valid enumerator of '" +
eDataType.getName() + "'");
return result;
}


To support nillable elements in XML Schema, we also generate another
wrapper data type that allows null (since EEnum-based feature never
return null) and the method for that looks like this

public BookCategory createBookCategoryObjectFromString(EDataType
eDataType, String initialValue)
{
return
createBookCategoryFromString(LibraryPackage.Literals.BOOK_CA TEGORY,
initialValue);
}

So a null value for EEum-based feature would always serialize an xsi:nil
and we'd make no attempt to convert a null string value to a literal of
that type, we'd just set the feature's value to null. So maybe this
deep copy method should guard against creating an instance from a null
string value...


Martin Taal wrote:
> Hi Jeff,
> Teneo tries to translate the PeriodObject to a string, to do this it
> also touches the underlying Period enum. Afaics you should change the
> JiemFactoryImpl.createPeriodFromString to handle null values to solve
> this.
>
> For my curiosity why does directly using the enum disallow null values?
>
> gr. Martin
>
> Jeff Bellegarde wrote:
>> I'm trying to save a model and receiving the following error.
>>
>>
>> java.lang.IllegalArgumentException: The value 'null' is not a valid
>> enumerator of 'Period'
>> at
>> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
>>
>> at
>> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
>>
>> at
>> org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
>>
>> at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
>> at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
>> at
>> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
>> at
>> org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
>> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
>> at
>> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>>
>> at
>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>>
>> at
>> org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
>> at
>> org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
>>
>> at
>> org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)
>>
>>
>>
>> The important section of the model is:
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Exchange">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
>> unique="false"
>> eType="#//PeriodObject" unsettable="true"/>
>> </eClassifiers>
>>
>> <eClassifiers xsi:type="ecore:EEnum" name="Period">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="Period"/>
>> </eAnnotations>
>> <eLiterals name="Hour"/>
>> <eLiterals name="Day" value="1"/>
>> <eLiterals name="Week" value="2"/>
>> <eLiterals name="Year" value="3"/>
>> <eLiterals name="Month" value="4"/>
>> </eClassifiers>
>>
>> <eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
>> instanceClassName="org.eclipse.emf.common.util.Enumerator">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="Period:Object"/>
>> <details key="baseType" value="Period"/>
>> </eAnnotations>
>> </eClassifiers>
>>
>> The indirection through PeriodObject is to allow Exchange.period to
>> be set to null. Pointing Exchange.period directly to Period saves
>> correctly, but disallows having a null period.
>>
>> It looks like Teneo is ignoring the PeriodObject and just dealing
>> with the Period enum which can not be null.
>>
>> Is there a way to get Teneo to save a null enum reference correctly?
>>
>>
>>
>>
>
>


--------------030906070809010207010804
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin,<br>
<br>
The generated code does this<br>
<blockquote><small>&nbsp; public BookCategory
createBookCategoryFromString(EDataType eDataType, String initialValue)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; BookCategory result = BookCategory.get(initialValue);</small><br>
<small>&nbsp;&nbsp;&nbsp; if (result == null) throw new
IllegalArgumentException("The value '" + initialValue + "' is not a
valid enumerator of '" + eDataType.getName() + "'");</small><br>
<small>&nbsp;&nbsp;&nbsp; return result;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<br>
To support nillable elements in XML Schema, we also generate another
wrapper data type that allows null (since EEnum-based feature never
return null) and the method for that looks like this<br>
<blockquote><small>&nbsp; public BookCategory
createBookCategoryObjectFromString(EDataType eDataType, String
initialValue)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; return
createBookCategoryFromString(LibraryPackage.Literals.BOOK_CA TEGORY,
initialValue);<br>
&nbsp; }</small><br>
</blockquote>
So a null value for EEum-based feature would always serialize an
xsi:nil and we'd make no attempt to convert a null string value to a
literal of that type, we'd just set the feature's value to null.&nbsp; So
maybe this deep copy method should guard against creating an instance
from a null string value...<br>
<br>
<br>
Martin Taal wrote:
<blockquote cite="mid:fafkto$ko4$1@build.eclipse.org" type="cite">Hi
Jeff,
<br>
Teneo tries to translate the PeriodObject to a string, to do this it
also touches the underlying Period enum. Afaics you should change the
JiemFactoryImpl.createPeriodFromString to handle null values to solve
this.
<br>
<br>
For my curiosity why does directly using the enum disallow null values?
<br>
<br>
gr. Martin
<br>
<br>
Jeff Bellegarde wrote:
<br>
<blockquote type="cite">I'm trying to save a model and receiving the
following error.
<br>
<br>
<br>
java.lang.IllegalArgumentException: The value 'null' is not a valid
enumerator of 'Period'
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
<br>
&nbsp;&nbsp;&nbsp; at
org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)
<br>
<br>
<br>
The important section of the model is:
<br>
<br>
&nbsp;&lt;eClassifiers xsi:type="ecore:EClass" name="Exchange"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
unique="false"
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; eType="#//PeriodObject" unsettable="true"/&gt;
<br>
&nbsp; &lt;/eClassifiers&gt;
<br>
<br>
&lt;eClassifiers xsi:type="ecore:EEnum" name="Period"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="name" value="Period"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/eAnnotations&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Hour"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Day" value="1"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Week" value="2"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Year" value="3"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Month" value="4"/&gt;
<br>
&nbsp; &lt;/eClassifiers&gt;
<br>
<br>
&lt;eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
instanceClassName="org.eclipse.emf.common.util.Enumerator"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="name" value="Period:Object"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="baseType" value="Period"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/eAnnotations&gt;
<br>
&nbsp;&lt;/eClassifiers&gt;
<br>
<br>
The indirection through PeriodObject is to allow Exchange.period to be
set to null. Pointing Exchange.period directly to Period saves
correctly, but disallows having a null period.
<br>
<br>
It looks like Teneo is ignoring the PeriodObject and just dealing with
the Period enum which can not be null.
<br>
<br>
Is there a way to get Teneo to save a null enum reference correctly?
<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------030906070809010207010804--
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #93851 is a reply to message #93818] Tue, 21 August 2007 23:38 Go to previous messageGo to next message
Jeff Bellegarde is currently offline Jeff BellegardeFriend
Messages: 6
Registered: July 2009
Junior Member
Martin Taal wrote:
> Hi Jeff,
> Teneo tries to translate the PeriodObject to a string, to do this it
> also touches the underlying Period enum. Afaics you should change the
> JiemFactoryImpl.createPeriodFromString to handle null values to solve this.
>

Hmmm... Other callers of that method have reason to assume it will never
return null. Changing that could reasonably cause other problems down
the line. I'm not sure how to reasonably tell if that would be safe or
not. Anybody happen to know, one way or the other?

It seems like intercepting higher up in the stack would be safer. The
deepCopy method seems like a reasonable possibly (as Ed suggested), but
outside of my knowledge.

> For my curiosity why does directly using the enum disallow null values?

Why? No idea. But it certainly seems to. We've tried multiple approaches
but I haven't been able to create an object with null value for
enumeration field. The closes we've come is the trick we are using. If
you know another way, I would love to hear it.

>
> gr. Martin
>
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #93882 is a reply to message #93851] Wed, 22 August 2007 06:11 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
From the stacktrace I can see that Teneo uses the default usertype to persist the PeriodObject:
org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype

So to prevent this issue you can implement your own hibernate user type and use that to persist the
PeriodObject. You can specify that your usertype should be used by setting the TypeDef or Type
annotation (you can set it on the edatatype):
@TypeDef(name="nameType" typeClass=" org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameTyp e ")

See the elver.org website for more information on how to set annotations.

gr. Martin

Jeff Bellegarde wrote:
> Martin Taal wrote:
>> Hi Jeff,
>> Teneo tries to translate the PeriodObject to a string, to do this it
>> also touches the underlying Period enum. Afaics you should change the
>> JiemFactoryImpl.createPeriodFromString to handle null values to solve
>> this.
>>
>
> Hmmm... Other callers of that method have reason to assume it will never
> return null. Changing that could reasonably cause other problems down
> the line. I'm not sure how to reasonably tell if that would be safe or
> not. Anybody happen to know, one way or the other?
>
> It seems like intercepting higher up in the stack would be safer. The
> deepCopy method seems like a reasonable possibly (as Ed suggested), but
> outside of my knowledge.
>
>> For my curiosity why does directly using the enum disallow null values?
>
> Why? No idea. But it certainly seems to. We've tried multiple approaches
> but I haven't been able to create an object with null value for
> enumeration field. The closes we've come is the trick we are using. If
> you know another way, I would love to hear it.
>
>>
>> gr. Martin
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #93989 is a reply to message #93882] Wed, 22 August 2007 18:41 Go to previous message
Jeff Bellegarde is currently offline Jeff BellegardeFriend
Messages: 6
Registered: July 2009
Junior Member
Excellent. That takes care of it. The existing EnumUserType appears to
do what I need.

The end classifier declaration

<eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
instanceClassName="org.eclipse.emf.common.util.Enumerator">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Period:Object"/>
<details key="baseType" value="Period"/>
</eAnnotations>
<eAnnotations source="teneo.jpa">
<details key="value" value="@TypeDef(name=&quot;periodEnum&quot;,
typeClass=&quot;org.eclipse.emf.teneo.hibernate.mapping. ENumUserType&quot;parameters
= @Parameter(name=&quot;enumClass&quot;,
value=&quot;org.search.jiem.model.Period&quot;)
})"/>
</eAnnotations>
</eClassifiers>

Thanks for your help.

Martin Taal wrote:
> From the stacktrace I can see that Teneo uses the default usertype to
> persist the PeriodObject:
> org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype
>
> So to prevent this issue you can implement your own hibernate user type
> and use that to persist the PeriodObject. You can specify that your
> usertype should be used by setting the TypeDef or Type annotation (you
> can set it on the edatatype):
> @TypeDef(name="nameType"
> typeClass=" org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameTyp e ")
>
> See the elver.org website for more information on how to set annotations.
>
> gr. Martin
>
> Jeff Bellegarde wrote:
>> Martin Taal wrote:
>>> Hi Jeff,
>>> Teneo tries to translate the PeriodObject to a string, to do this it
>>> also touches the underlying Period enum. Afaics you should change the
>>> JiemFactoryImpl.createPeriodFromString to handle null values to solve
>>> this.
>>>
>>
>> Hmmm... Other callers of that method have reason to assume it will
>> never return null. Changing that could reasonably cause other problems
>> down the line. I'm not sure how to reasonably tell if that would be
>> safe or not. Anybody happen to know, one way or the other?
>>
>> It seems like intercepting higher up in the stack would be safer. The
>> deepCopy method seems like a reasonable possibly (as Ed suggested),
>> but outside of my knowledge.
>>
>>> For my curiosity why does directly using the enum disallow null values?
>>
>> Why? No idea. But it certainly seems to. We've tried multiple
>> approaches but I haven't been able to create an object with null value
>> for enumeration field. The closes we've come is the trick we are
>> using. If you know another way, I would love to hear it.
>>
>>>
>>> gr. Martin
>>>
>>
>
>
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #609498 is a reply to message #93802] Tue, 21 August 2007 21:19 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jeff,
Teneo tries to translate the PeriodObject to a string, to do this it also touches the underlying
Period enum. Afaics you should change the JiemFactoryImpl.createPeriodFromString to handle null
values to solve this.

For my curiosity why does directly using the enum disallow null values?

gr. Martin

Jeff Bellegarde wrote:
> I'm trying to save a model and receiving the following error.
>
>
> java.lang.IllegalArgumentException: The value 'null' is not a valid
> enumerator of 'Period'
> at
> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
>
> at
> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
>
> at
> org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
>
> at
> org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
>
> at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
> at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
> at
> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
> at
> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>
> at
> org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>
> at
> org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
> at
> org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
>
> at
> org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)
>
>
>
> The important section of the model is:
>
> <eClassifiers xsi:type="ecore:EClass" name="Exchange">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
> unique="false"
> eType="#//PeriodObject" unsettable="true"/>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EEnum" name="Period">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Period"/>
> </eAnnotations>
> <eLiterals name="Hour"/>
> <eLiterals name="Day" value="1"/>
> <eLiterals name="Week" value="2"/>
> <eLiterals name="Year" value="3"/>
> <eLiterals name="Month" value="4"/>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
> instanceClassName="org.eclipse.emf.common.util.Enumerator">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Period:Object"/>
> <details key="baseType" value="Period"/>
> </eAnnotations>
> </eClassifiers>
>
> The indirection through PeriodObject is to allow Exchange.period to be
> set to null. Pointing Exchange.period directly to Period saves
> correctly, but disallows having a null period.
>
> It looks like Teneo is ignoring the PeriodObject and just dealing with
> the Period enum which can not be null.
>
> Is there a way to get Teneo to save a null enum reference correctly?
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #609499 is a reply to message #93818] Tue, 21 August 2007 21:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 32430
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030906070809010207010804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

The generated code does this

public BookCategory createBookCategoryFromString(EDataType
eDataType, String initialValue)
{
BookCategory result = BookCategory.get(initialValue);
if (result == null) throw new IllegalArgumentException("The
value '" + initialValue + "' is not a valid enumerator of '" +
eDataType.getName() + "'");
return result;
}


To support nillable elements in XML Schema, we also generate another
wrapper data type that allows null (since EEnum-based feature never
return null) and the method for that looks like this

public BookCategory createBookCategoryObjectFromString(EDataType
eDataType, String initialValue)
{
return
createBookCategoryFromString(LibraryPackage.Literals.BOOK_CA TEGORY,
initialValue);
}

So a null value for EEum-based feature would always serialize an xsi:nil
and we'd make no attempt to convert a null string value to a literal of
that type, we'd just set the feature's value to null. So maybe this
deep copy method should guard against creating an instance from a null
string value...


Martin Taal wrote:
> Hi Jeff,
> Teneo tries to translate the PeriodObject to a string, to do this it
> also touches the underlying Period enum. Afaics you should change the
> JiemFactoryImpl.createPeriodFromString to handle null values to solve
> this.
>
> For my curiosity why does directly using the enum disallow null values?
>
> gr. Martin
>
> Jeff Bellegarde wrote:
>> I'm trying to save a model and receiving the following error.
>>
>>
>> java.lang.IllegalArgumentException: The value 'null' is not a valid
>> enumerator of 'Period'
>> at
>> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
>>
>> at
>> org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
>>
>> at
>> org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
>>
>> at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
>> at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
>> at
>> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
>> at
>> org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
>> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
>> at
>> org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
>> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
>>
>> at
>> org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
>>
>> at
>> org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
>> at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
>> at
>> org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
>>
>> at
>> org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)
>>
>>
>>
>> The important section of the model is:
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Exchange">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
>> unique="false"
>> eType="#//PeriodObject" unsettable="true"/>
>> </eClassifiers>
>>
>> <eClassifiers xsi:type="ecore:EEnum" name="Period">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="Period"/>
>> </eAnnotations>
>> <eLiterals name="Hour"/>
>> <eLiterals name="Day" value="1"/>
>> <eLiterals name="Week" value="2"/>
>> <eLiterals name="Year" value="3"/>
>> <eLiterals name="Month" value="4"/>
>> </eClassifiers>
>>
>> <eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
>> instanceClassName="org.eclipse.emf.common.util.Enumerator">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="Period:Object"/>
>> <details key="baseType" value="Period"/>
>> </eAnnotations>
>> </eClassifiers>
>>
>> The indirection through PeriodObject is to allow Exchange.period to
>> be set to null. Pointing Exchange.period directly to Period saves
>> correctly, but disallows having a null period.
>>
>> It looks like Teneo is ignoring the PeriodObject and just dealing
>> with the Period enum which can not be null.
>>
>> Is there a way to get Teneo to save a null enum reference correctly?
>>
>>
>>
>>
>
>


--------------030906070809010207010804
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin,<br>
<br>
The generated code does this<br>
<blockquote><small>&nbsp; public BookCategory
createBookCategoryFromString(EDataType eDataType, String initialValue)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; BookCategory result = BookCategory.get(initialValue);</small><br>
<small>&nbsp;&nbsp;&nbsp; if (result == null) throw new
IllegalArgumentException("The value '" + initialValue + "' is not a
valid enumerator of '" + eDataType.getName() + "'");</small><br>
<small>&nbsp;&nbsp;&nbsp; return result;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<br>
To support nillable elements in XML Schema, we also generate another
wrapper data type that allows null (since EEnum-based feature never
return null) and the method for that looks like this<br>
<blockquote><small>&nbsp; public BookCategory
createBookCategoryObjectFromString(EDataType eDataType, String
initialValue)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; return
createBookCategoryFromString(LibraryPackage.Literals.BOOK_CA TEGORY,
initialValue);<br>
&nbsp; }</small><br>
</blockquote>
So a null value for EEum-based feature would always serialize an
xsi:nil and we'd make no attempt to convert a null string value to a
literal of that type, we'd just set the feature's value to null.&nbsp; So
maybe this deep copy method should guard against creating an instance
from a null string value...<br>
<br>
<br>
Martin Taal wrote:
<blockquote cite="mid:fafkto$ko4$1@build.eclipse.org" type="cite">Hi
Jeff,
<br>
Teneo tries to translate the PeriodObject to a string, to do this it
also touches the underlying Period enum. Afaics you should change the
JiemFactoryImpl.createPeriodFromString to handle null values to solve
this.
<br>
<br>
For my curiosity why does directly using the enum disallow null values?
<br>
<br>
gr. Martin
<br>
<br>
Jeff Bellegarde wrote:
<br>
<blockquote type="cite">I'm trying to save a model and receiving the
following error.
<br>
<br>
<br>
java.lang.IllegalArgumentException: The value 'null' is not a valid
enumerator of 'Period'
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.model.impl.JiemFactoryImpl.createPeriodFromS tring(JiemFactoryImpl.java:565)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.model.impl.JiemFactoryImpl.createPeriodObjec tFromString(JiemFactoryImpl.java:527)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.model.impl.JiemFactoryImpl.createFromString( JiemFactoryImpl.java:141)
<br>
&nbsp;&nbsp;&nbsp; at
org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype.deepCopy(DefaultToStringUserType.java:77)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.type.CustomType.deepCopy(CustomType.java:179)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:354 )
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:274)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:437)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:326)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.cascadeBef oreSave(AbstractSaveEventListener.java:412)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:261)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:180)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:121)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:186)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveEventListener.saveWithGen eratedOrRequestedId(DefaultSaveEventListener.java:33)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveEventListener.performSave OrUpdate(DefaultSaveEventListener.java:27)
<br>
&nbsp;&nbsp;&nbsp; at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535 )
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
<br>
&nbsp;&nbsp;&nbsp; at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.exporting.ExportSiteModel.storeInDatabase(Ex portSiteModel.java:35)
<br>
&nbsp;&nbsp;&nbsp; at
org.search.jiem.exporting.ExportSiteModelTest.testSimple(Exp ortSiteModelTest.java:164)
<br>
<br>
<br>
The important section of the model is:
<br>
<br>
&nbsp;&lt;eClassifiers xsi:type="ecore:EClass" name="Exchange"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="period"
unique="false"
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; eType="#//PeriodObject" unsettable="true"/&gt;
<br>
&nbsp; &lt;/eClassifiers&gt;
<br>
<br>
&lt;eClassifiers xsi:type="ecore:EEnum" name="Period"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="name" value="Period"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/eAnnotations&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Hour"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Day" value="1"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Week" value="2"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Year" value="3"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eLiterals name="Month" value="4"/&gt;
<br>
&nbsp; &lt;/eClassifiers&gt;
<br>
<br>
&lt;eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
instanceClassName="org.eclipse.emf.common.util.Enumerator"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="name" value="Period:Object"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="baseType" value="Period"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/eAnnotations&gt;
<br>
&nbsp;&lt;/eClassifiers&gt;
<br>
<br>
The indirection through PeriodObject is to allow Exchange.period to be
set to null. Pointing Exchange.period directly to Period saves
correctly, but disallows having a null period.
<br>
<br>
It looks like Teneo is ignoring the PeriodObject and just dealing with
the Period enum which can not be null.
<br>
<br>
Is there a way to get Teneo to save a null enum reference correctly?
<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------030906070809010207010804--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #609500 is a reply to message #93818] Tue, 21 August 2007 23:38 Go to previous message
Jeff Bellegarde is currently offline Jeff BellegardeFriend
Messages: 6
Registered: July 2009
Junior Member
Martin Taal wrote:
> Hi Jeff,
> Teneo tries to translate the PeriodObject to a string, to do this it
> also touches the underlying Period enum. Afaics you should change the
> JiemFactoryImpl.createPeriodFromString to handle null values to solve this.
>

Hmmm... Other callers of that method have reason to assume it will never
return null. Changing that could reasonably cause other problems down
the line. I'm not sure how to reasonably tell if that would be safe or
not. Anybody happen to know, one way or the other?

It seems like intercepting higher up in the stack would be safer. The
deepCopy method seems like a reasonable possibly (as Ed suggested), but
outside of my knowledge.

> For my curiosity why does directly using the enum disallow null values?

Why? No idea. But it certainly seems to. We've tried multiple approaches
but I haven't been able to create an object with null value for
enumeration field. The closes we've come is the trick we are using. If
you know another way, I would love to hear it.

>
> gr. Martin
>
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #609502 is a reply to message #93851] Wed, 22 August 2007 06:11 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
From the stacktrace I can see that Teneo uses the default usertype to persist the PeriodObject:
org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype

So to prevent this issue you can implement your own hibernate user type and use that to persist the
PeriodObject. You can specify that your usertype should be used by setting the TypeDef or Type
annotation (you can set it on the edatatype):
@TypeDef(name="nameType" typeClass=" org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameTyp e ")

See the elver.org website for more information on how to set annotations.

gr. Martin

Jeff Bellegarde wrote:
> Martin Taal wrote:
>> Hi Jeff,
>> Teneo tries to translate the PeriodObject to a string, to do this it
>> also touches the underlying Period enum. Afaics you should change the
>> JiemFactoryImpl.createPeriodFromString to handle null values to solve
>> this.
>>
>
> Hmmm... Other callers of that method have reason to assume it will never
> return null. Changing that could reasonably cause other problems down
> the line. I'm not sure how to reasonably tell if that would be safe or
> not. Anybody happen to know, one way or the other?
>
> It seems like intercepting higher up in the stack would be safer. The
> deepCopy method seems like a reasonable possibly (as Ed suggested), but
> outside of my knowledge.
>
>> For my curiosity why does directly using the enum disallow null values?
>
> Why? No idea. But it certainly seems to. We've tried multiple approaches
> but I haven't been able to create an object with null value for
> enumeration field. The closes we've come is the trick we are using. If
> you know another way, I would love to hear it.
>
>>
>> gr. Martin
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Illegal Argument Exception saving null object enumeration [message #609509 is a reply to message #93882] Wed, 22 August 2007 18:41 Go to previous message
Jeff Bellegarde is currently offline Jeff BellegardeFriend
Messages: 6
Registered: July 2009
Junior Member
Excellent. That takes care of it. The existing EnumUserType appears to
do what I need.

The end classifier declaration

<eClassifiers xsi:type="ecore:EDataType" name="PeriodObject"
instanceClassName="org.eclipse.emf.common.util.Enumerator">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Period:Object"/>
<details key="baseType" value="Period"/>
</eAnnotations>
<eAnnotations source="teneo.jpa">
<details key="value" value="@TypeDef(name=&quot;periodEnum&quot;,
typeClass=&quot;org.eclipse.emf.teneo.hibernate.mapping. ENumUserType&quot;parameters
= @Parameter(name=&quot;enumClass&quot;,
value=&quot;org.search.jiem.model.Period&quot;)
})"/>
</eAnnotations>
</eClassifiers>

Thanks for your help.

Martin Taal wrote:
> From the stacktrace I can see that Teneo uses the default usertype to
> persist the PeriodObject:
> org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserT ype
>
> So to prevent this issue you can implement your own hibernate user type
> and use that to persist the PeriodObject. You can specify that your
> usertype should be used by setting the TypeDef or Type annotation (you
> can set it on the edatatype):
> @TypeDef(name="nameType"
> typeClass=" org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameTyp e ")
>
> See the elver.org website for more information on how to set annotations.
>
> gr. Martin
>
> Jeff Bellegarde wrote:
>> Martin Taal wrote:
>>> Hi Jeff,
>>> Teneo tries to translate the PeriodObject to a string, to do this it
>>> also touches the underlying Period enum. Afaics you should change the
>>> JiemFactoryImpl.createPeriodFromString to handle null values to solve
>>> this.
>>>
>>
>> Hmmm... Other callers of that method have reason to assume it will
>> never return null. Changing that could reasonably cause other problems
>> down the line. I'm not sure how to reasonably tell if that would be
>> safe or not. Anybody happen to know, one way or the other?
>>
>> It seems like intercepting higher up in the stack would be safer. The
>> deepCopy method seems like a reasonable possibly (as Ed suggested),
>> but outside of my knowledge.
>>
>>> For my curiosity why does directly using the enum disallow null values?
>>
>> Why? No idea. But it certainly seems to. We've tried multiple
>> approaches but I haven't been able to create an object with null value
>> for enumeration field. The closes we've come is the trick we are
>> using. If you know another way, I would love to hear it.
>>
>>>
>>> gr. Martin
>>>
>>
>
>
Previous Topic:[Teneo] Resource.getEObject() method throws exception instead of null
Next Topic:Teneo Query By Example
Goto Forum:
  


Current Time: Mon Aug 08 23:06:21 GMT 2022

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

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

Back to the top