[CDO/Hibernate/Teneo] java.lang.String cannot be cast to java.lang.Long [message #871512] |
Mon, 14 May 2012 09:58 |
Erdal Karaca Messages: 854 Registered: July 2009 |
Senior Member |
|
|
I have a case where a String is provided whereas a Long is expected:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at org.hibernate.type.descriptor.java.LongTypeDescriptor.unwrap(LongTypeDescriptor.java:36)
at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$1.doBind(BigIntTypeDescriptor.java:52)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:89)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:282)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:277)
at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:85)
at org.hibernate.type.AnyType.nullSafeSet(AnyType.java:162)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:815)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1203)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:188)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.doWrite(HibernateStoreAccessor.java:689)
at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:487)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:43)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:262)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:96)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326)
at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251)
at org.eclipse.net4j.signal.Signal.run(Signal.java:147)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Hints:
- org.hibernate.type.descriptor.sql.new BasicBinder() {...}.doBind(PreparedStatement, X, int, WrapperOptions)
-> value of X is a String (UUID)
- JavaTypeDescriptor is instanceof LongTypeDescriptor which leads to the ClassCastException when the String UUID is provided to org.hibernate.type.descriptor.java.JavaTypeDescriptor.unwrap(Long, Class<Long>, WrapperOptions)
The insert statement which is being executed:
Hibernate: insert into [pictogramlink_businessobjects] ([pictogramlink_e_id], [businessobjects_type], [businessobjects_id]) values (?, ?, ?)
Notes:
This is the linkage insert, i.e. a Graphiti Pictogram Element (legacy mode, pictogramlink_e_id) is linked to a business object from our own meta-model...
Maybe, some sort of CDOID types mismatch?
|
|
|
Re: [CDO/Hibernate/Teneo] java.lang.String cannot be cast to java.lang.Long [message #871543 is a reply to message #871512] |
Mon, 14 May 2012 11:22 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Erdal,
Afaics this is a so-called anytype ereference, so the model does not explicitly define the type, it is EObject. To model
this correctly with strings you would need to add this annotation to the graphitic ecore:
@AnyMetaDef(idType =
"string",metaType = "string")
but then all your types stored in this ereference should have a string idtype.
Note that if you don't control the graphiti model then you can also use xml to define annotations:
http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Annotations_Format#JPA_Annotations_in_XML
Or you can use an external reference, so map this ereference as an external link instead of as an anytype:
http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Association_Mapping#Storing_external_references_.28to_non-persisted_objects.29.2C_customizing_persisting_references
gr. Martin
On 05/14/2012 11:58 AM, Erdal Karaca wrote:
> I have a case where a String is provided whereas a Long is expected:
>
>
> java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
> at org.hibernate.type.descriptor.java.LongTypeDescriptor.unwrap(LongTypeDescriptor.java:36)
> at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$1.doBind(BigIntTypeDescriptor.java:52)
> at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:89)
> at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:282)
> at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:277)
> at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:85)
> at org.hibernate.type.AnyType.nullSafeSet(AnyType.java:162)
> at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:815)
> at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1203)
> at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:188)
> at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
> at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.doWrite(HibernateStoreAccessor.java:689)
> at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
> at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:487)
> at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:43)
> at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
> at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:262)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:96)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
>
> at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
> at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326)
> at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
> at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251)
> at org.eclipse.net4j.signal.Signal.run(Signal.java:147)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
>
> Hints:
> - org.hibernate.type.descriptor.sql.new BasicBinder() {...}.doBind(PreparedStatement, X, int, WrapperOptions)
> -> value of X is a String (UUID)
> - JavaTypeDescriptor is instanceof LongTypeDescriptor which leads to the ClassCastException when the String UUID is
> provided to org.hibernate.type.descriptor.java.JavaTypeDescriptor.unwrap(Long, Class<Long>, WrapperOptions)
>
> The insert statement which is being executed:
>
>
> Hibernate: insert into [pictogramlink_businessobjects] ([pictogramlink_e_id], [businessobjects_type],
> [businessobjects_id]) values (?, ?, ?)
>
>
> Notes:
> This is the linkage insert, i.e. a Graphiti Pictogram Element (legacy mode, pictogramlink_e_id) is linked to a business
> object from our own meta-model...
> Maybe, some sort of CDOID types mismatch?
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
|
|
|
Re: [CDO/Hibernate/Teneo] java.lang.String cannot be cast to java.lang.Long [message #871629 is a reply to message #871622] |
Mon, 14 May 2012 15:03 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Erdal,
Looking back at the xml, I think it is wrong, the any-metadef should be on a property/ereference not on epackage level.
This zip file contains several examples on how to do things in xml:
http://wiki.eclipse.org/images/4/48/Teneo_XML_Annotations_Examples.zip
gr. Martin
On 05/14/2012 04:44 PM, Erdal Karaca wrote:
> Yes, cdo says that it cannot find the (graphiti) packages, but I am allowed to ignore it if the packages are registered
> later... And that is the case, they are registered when specific instances of the graphiti packages are serialized:
>
>
> !MESSAGE No EPackage found for namespace http://eclipse.org/graphiti/mm/algorithms/styles. This is not a problem if this
> EPackage is registered later.
>
> [same for other graphiti epackages]
>
>
> And I have debugged down to the location where the xml file is read and parsed:
> org.eclipse.emf.teneo.annotations.mapper.PersistenceMappingBuilder.buildMapping(List<EPackage>, PersistenceOptions,
> ExtensionManager)
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Powered by
FUDForum. Page generated in 0.04039 seconds