Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Persisting GMF diagram: Integer cannot be cast to Long
[Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #115340] Sat, 22 March 2008 13:38 Go to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hello!

Thank you very much for implementing the feature to persist the GMF
diagram to a database.

But certainly I am not able to manage it.

A followed the tutorial on elver.org, but I get the following exception
when the save method of the resource gets called:

835872 [main] ERROR org.eclipse.emf.teneo.hibernate.HbMapperException -
Exception when saving resource odm_jobplan
java.lang.ClassCastException: java.lang.Integer cannot be cast to
java.lang.Long
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.jav a:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.jav a:107)
at org.hibernate.type.AnyType.nullSafeSet(AnyType.java:144)
at
org.hibernate.persister.entity.AbstractEntityPersister.dehyd rate(AbstractEntityPersister.java:1997)
at
org.hibernate.persister.entity.AbstractEntityPersister.inser t(AbstractEntityPersister.java:2243)
at
org.hibernate.persister.entity.AbstractEntityPersister.inser t(AbstractEntityPersister.java:2660)
at
org.hibernate.action.EntityInsertAction.execute(EntityInsert Action.java:56)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:25 0)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:141)
at
org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at
org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSes sionWrapper.java:161)
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:348)
at
org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:348)



Here some more trace back:
835832 [main] DEBUG org.hibernate.SQL - insert into "ecore_eobject"
(e_version, econtainer_class, e_container, e_container_featureid,
"visible", "type", "element_type", "element_id", "name",
"measurementunit", "dtype", e_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
'Diagram', ?)
835832 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing
statement
835842 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister
- Dehydrating entity: [Diagram#65539]
835842 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to
parameter: 1
835842 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to
parameter: 4
835842 [main] DEBUG org.hibernate.type.BooleanType - binding 'true' to
parameter: 5
835842 [main] DEBUG org.hibernate.type.StringType - binding 'Odm' to
parameter: 6
835842 [main] DEBUG org.hibernate.type.StringType - binding 'Jobplan' to
parameter: 7
835842 [main] DEBUG org.hibernate.type.LongType - binding '32768' to
parameter: 8
835842 [main] INFO org.hibernate.type.LongType - could not bind value
'32768' to parameter: 8; java.lang.Integer cannot be cast to java.lang.Long
835842 [main] DEBUG org.hibernate.jdbc.ConnectionManager - registering
flush end


Persisting my on model "Jobplan" works fine, but persisting the "Diagram"
doesn't work :(!

Thank you very any help!

Best regards,
Matthias
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #115353 is a reply to message #115340] Sat, 22 March 2008 20:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matthias,
Apparently the id of the JobPlan is an Integer while hibernate expects a Long. Is the id in the
JobPlan entity computed by the db or set by yourselve?

gr. Martin

Matthias wrote:
> Hello!
>
> Thank you very much for implementing the feature to persist the GMF
> diagram to a database.
>
> But certainly I am not able to manage it.
>
> A followed the tutorial on elver.org, but I get the following exception
> when the save method of the resource gets called:
>
> 835872 [main] ERROR org.eclipse.emf.teneo.hibernate.HbMapperException -
> Exception when saving resource odm_jobplan
> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> java.lang.Long
> at org.hibernate.type.LongType.set(LongType.java:42)
> at org.hibernate.type.NullableType.nullSafeSet(NullableType.jav a:136)
> at org.hibernate.type.NullableType.nullSafeSet(NullableType.jav a:107)
> at org.hibernate.type.AnyType.nullSafeSet(AnyType.java:144)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.dehyd rate(AbstractEntityPersister.java:1997)
>
> at
> org.hibernate.persister.entity.AbstractEntityPersister.inser t(AbstractEntityPersister.java:2243)
>
> at
> org.hibernate.persister.entity.AbstractEntityPersister.inser t(AbstractEntityPersister.java:2660)
>
> at
> org.hibernate.action.EntityInsertAction.execute(EntityInsert Action.java:56)
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:25 0)
> at
> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:234)
> at
> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:141)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSes sionWrapper.java:161)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:348)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:348)
>
>
>
> Here some more trace back:
> 835832 [main] DEBUG org.hibernate.SQL - insert into "ecore_eobject"
> (e_version, econtainer_class, e_container, e_container_featureid,
> "visible", "type", "element_type", "element_id", "name",
> "measurementunit", "dtype", e_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> 'Diagram', ?)
> 835832 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing
> statement
> 835842 [main] DEBUG
> org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating
> entity: [Diagram#65539]
> 835842 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to
> parameter: 1
> 835842 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to
> parameter: 4
> 835842 [main] DEBUG org.hibernate.type.BooleanType - binding 'true' to
> parameter: 5
> 835842 [main] DEBUG org.hibernate.type.StringType - binding 'Odm' to
> parameter: 6
> 835842 [main] DEBUG org.hibernate.type.StringType - binding 'Jobplan'
> to parameter: 7
> 835842 [main] DEBUG org.hibernate.type.LongType - binding '32768' to
> parameter: 8
> 835842 [main] INFO org.hibernate.type.LongType - could not bind value
> '32768' to parameter: 8; java.lang.Integer cannot be cast to java.lang.Long
> 835842 [main] DEBUG org.hibernate.jdbc.ConnectionManager - registering
> flush end
>
>
> Persisting my on model "Jobplan" works fine, but persisting the
> "Diagram" doesn't work :(!
>
> Thank you very any help!
>
> Best regards,
> Matthias
>
>


--

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] Persisting GMF diagram: Integer cannot be cast to Long [message #115604 is a reply to message #115353] Tue, 25 March 2008 09:13 Go to previous messageGo to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hello Martin!

I dont know Hibernate very well ...

My Ecore model has a base EClass "IdObject" that contains the attribute
"id" of type EInt.
When I change the id attribute to type ELong, everything works fine... My
model instance gets persisted. I followed excatly the turtorial for the
GMF Mindmap editor and so Teneo automatically creates the mapping
definition for Hibernate.

I think the error was a good hint, because long is a better type for an
id.
But why does Hibernate/Teneo only work with long/ELong?!

Best regards,
Matthias
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #115617 is a reply to message #115604] Tue, 25 March 2008 09:15 Go to previous messageGo to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
... and no I don't set the id manually ....
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #115629 is a reply to message #115604] Tue, 25 March 2008 09:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matthias,
Teneo/Hibernate should also work fine with int.

You can check the generated mapping if the id is mapped as an int or long (when the id type is int).
Did you annotate the attribute id with the @Id annotation or is its ID ecore property true?

gr. Martin

Matthias wrote:
> Hello Martin!
>
> I dont know Hibernate very well ...
>
> My Ecore model has a base EClass "IdObject" that contains the attribute
> "id" of type EInt.
> When I change the id attribute to type ELong, everything works fine...
> My model instance gets persisted. I followed excatly the turtorial for
> the GMF Mindmap editor and so Teneo automatically creates the mapping
> definition for Hibernate.
>
> I think the error was a good hint, because long is a better type for an
> id. But why does Hibernate/Teneo only work with long/ELong?!
>
> Best regards,
> Matthias
>


--

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] Persisting GMF diagram: Integer cannot be cast to Long [message #115752 is a reply to message #115629] Wed, 26 March 2008 08:01 Go to previous messageGo to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hi Martin!

My IdObject.id attribute has the ECore property "ID" set to true.

Best regards,
Matthias
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #115765 is a reply to message #115752] Wed, 26 March 2008 08:15 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matthias,
It is possible that the mapping is wrong (always long instead of int). If you have time can you
check what mapping is generated when the id type is eint?
The mapping can be retrieved from the datastore through the getmappingxml method.

gr. Martin

Matthias wrote:
> Hi Martin!
>
> My IdObject.id attribute has the ECore property "ID" set to true.
>
> Best regards,
> Matthias
>


--

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] Persisting GMF diagram: Integer cannot be cast to Long [message #615950 is a reply to message #115340] Sat, 22 March 2008 20:26 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matthias,
Apparently the id of the JobPlan is an Integer while hibernate expects a Long. Is the id in the
JobPlan entity computed by the db or set by yourselve?

gr. Martin

Matthias wrote:
> Hello!
>
> Thank you very much for implementing the feature to persist the GMF
> diagram to a database.
>
> But certainly I am not able to manage it.
>
> A followed the tutorial on elver.org, but I get the following exception
> when the save method of the resource gets called:
>
> 835872 [main] ERROR org.eclipse.emf.teneo.hibernate.HbMapperException -
> Exception when saving resource odm_jobplan
> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> java.lang.Long
> at org.hibernate.type.LongType.set(LongType.java:42)
> at org.hibernate.type.NullableType.nullSafeSet(NullableType.jav a:136)
> at org.hibernate.type.NullableType.nullSafeSet(NullableType.jav a:107)
> at org.hibernate.type.AnyType.nullSafeSet(AnyType.java:144)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.dehyd rate(AbstractEntityPersister.java:1997)
>
> at
> org.hibernate.persister.entity.AbstractEntityPersister.inser t(AbstractEntityPersister.java:2243)
>
> at
> org.hibernate.persister.entity.AbstractEntityPersister.inser t(AbstractEntityPersister.java:2660)
>
> at
> org.hibernate.action.EntityInsertAction.execute(EntityInsert Action.java:56)
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:25 0)
> at
> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:234)
> at
> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:141)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSes sionWrapper.java:161)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:348)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou rce.java:348)
>
>
>
> Here some more trace back:
> 835832 [main] DEBUG org.hibernate.SQL - insert into "ecore_eobject"
> (e_version, econtainer_class, e_container, e_container_featureid,
> "visible", "type", "element_type", "element_id", "name",
> "measurementunit", "dtype", e_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
> 'Diagram', ?)
> 835832 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing
> statement
> 835842 [main] DEBUG
> org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating
> entity: [Diagram#65539]
> 835842 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to
> parameter: 1
> 835842 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to
> parameter: 4
> 835842 [main] DEBUG org.hibernate.type.BooleanType - binding 'true' to
> parameter: 5
> 835842 [main] DEBUG org.hibernate.type.StringType - binding 'Odm' to
> parameter: 6
> 835842 [main] DEBUG org.hibernate.type.StringType - binding 'Jobplan'
> to parameter: 7
> 835842 [main] DEBUG org.hibernate.type.LongType - binding '32768' to
> parameter: 8
> 835842 [main] INFO org.hibernate.type.LongType - could not bind value
> '32768' to parameter: 8; java.lang.Integer cannot be cast to java.lang.Long
> 835842 [main] DEBUG org.hibernate.jdbc.ConnectionManager - registering
> flush end
>
>
> Persisting my on model "Jobplan" works fine, but persisting the
> "Diagram" doesn't work :(!
>
> Thank you very any help!
>
> Best regards,
> Matthias
>
>


--

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] Persisting GMF diagram: Integer cannot be cast to Long [message #615969 is a reply to message #115353] Tue, 25 March 2008 09:13 Go to previous message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hello Martin!

I dont know Hibernate very well ...

My Ecore model has a base EClass "IdObject" that contains the attribute
"id" of type EInt.
When I change the id attribute to type ELong, everything works fine... My
model instance gets persisted. I followed excatly the turtorial for the
GMF Mindmap editor and so Teneo automatically creates the mapping
definition for Hibernate.

I think the error was a good hint, because long is a better type for an
id.
But why does Hibernate/Teneo only work with long/ELong?!

Best regards,
Matthias
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #615970 is a reply to message #115604] Tue, 25 March 2008 09:15 Go to previous message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
... and no I don't set the id manually ....
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #615971 is a reply to message #115604] Tue, 25 March 2008 09:23 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matthias,
Teneo/Hibernate should also work fine with int.

You can check the generated mapping if the id is mapped as an int or long (when the id type is int).
Did you annotate the attribute id with the @Id annotation or is its ID ecore property true?

gr. Martin

Matthias wrote:
> Hello Martin!
>
> I dont know Hibernate very well ...
>
> My Ecore model has a base EClass "IdObject" that contains the attribute
> "id" of type EInt.
> When I change the id attribute to type ELong, everything works fine...
> My model instance gets persisted. I followed excatly the turtorial for
> the GMF Mindmap editor and so Teneo automatically creates the mapping
> definition for Hibernate.
>
> I think the error was a good hint, because long is a better type for an
> id. But why does Hibernate/Teneo only work with long/ELong?!
>
> Best regards,
> Matthias
>


--

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] Persisting GMF diagram: Integer cannot be cast to Long [message #615980 is a reply to message #115629] Wed, 26 March 2008 08:01 Go to previous message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hi Martin!

My IdObject.id attribute has the ECore property "ID" set to true.

Best regards,
Matthias
Re: [Teneo] Persisting GMF diagram: Integer cannot be cast to Long [message #615981 is a reply to message #115752] Wed, 26 March 2008 08:15 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Matthias,
It is possible that the mapping is wrong (always long instead of int). If you have time can you
check what mapping is generated when the id type is eint?
The mapping can be retrieved from the datastore through the getmappingxml method.

gr. Martin

Matthias wrote:
> Hi Martin!
>
> My IdObject.id attribute has the ECore property "ID" set to true.
>
> Best regards,
> Matthias
>


--

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
Previous Topic:installation problem on 3.3.1.1
Next Topic:[Teneo] Creating/Opening several GMF diagrams
Goto Forum:
  


Current Time: Fri Mar 29 10:27:47 GMT 2024

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

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

Back to the top