Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Enum serialization and second-level cache enabled
[CDO] Enum serialization and second-level cache enabled [message #1113646] Sat, 21 September 2013 13:03 Go to next message
rumburak r is currently offline rumburak rFriend
Messages: 17
Registered: July 2011
Junior Member
Hi,

Could someone give me the information, how enums should be properly modeled in the Hibernate Store with the second-level cache enabled? As long as I've worked with my own model and without second-level cache everything was ok, but with the second-level cache enabled I've always got a ClassCastException. Recently I tested an example model from CDO test cases and I've got the same ClassCastException. Is it a bug, or I do something wrong ?

Here is my code for the CDO test case. I worked with Hibernate 4.1 and CDO 4.2 (but in the previous versions I've got the same exception).

  public void testEnumWithSecondLevelCache() throws Exception
  {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    MangoParameter createMangoParameter = getMangoFactory().createMangoParameter();
    createMangoParameter.setName("Mango1");
    createMangoParameter.setPassing(ParameterPassing.BY_VALUE);

    resource.getContents().add(createMangoParameter);

    transaction.commit();
    session.close();
  }


and second-level cache properties

hibernate.cache.use_second_level_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
teneo.mapping.default_cache_strategy=READ_WRITE


The exception with the Mango model

Caused by: org.eclipse.emf.cdo.util.CommitException: Rollback in HibernateStore: java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EEnumLiteralImpl cannot be cast to java.io.Serializable
	at org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType.disassemble(CDOENumStringType.java:84)
	at org.hibernate.type.CustomType.disassemble(CustomType.java:140)
	at org.hibernate.type.TypeHelper.disassemble(TypeHelper.java:145)
	at org.hibernate.cache.spi.entry.CacheEntry.<init>(CacheEntry.java:71)
	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:161)
	at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276)
	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
	at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.doWrite(HibernateStoreAccessor.java:949)
	at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:150)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:609)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:46)
	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.internal.server.Repository.commitUnsynced(Repository.java:931)
	at org.eclipse.emf.cdo.internal.server.Repository.commit(Repository.java:924)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:315)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:100)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
	at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:87)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:92)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:328)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:65)
	at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:66)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:253)
	at org.eclipse.net4j.signal.Signal.run(Signal.java:149)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:636)



The exception with my own model.

Caused by: java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EEnumLiteralImpl cannot be cast to java.io.Serializable
	at org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOENumStringType.disassemble(CDOENumStringType.java:84)
	at org.hibernate.type.CustomType.disassemble(CustomType.java:140)
	at org.hibernate.type.TypeHelper.disassemble(TypeHelper.java:145)
	at org.hibernate.cache.spi.entry.CacheEntry.<init>(CacheEntry.java:71)
	at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:181)
	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:995)
	at org.hibernate.loader.Loader.doQuery(Loader.java:874)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
	at org.hibernate.loader.Loader.loadEntity(Loader.java:2042)
	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3710)
	at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:440)
	at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:421)
	at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:205)
	at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:252)
	at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:149)
	at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:992)
	at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:919)
	at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:610)
	at org.hibernate.type.EntityType.resolve(EntityType.java:438)
	at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:150)
	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:995)
	at org.hibernate.loader.Loader.doQuery(Loader.java:874)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
	at org.hibernate.loader.Loader.loadCollection(Loader.java:2159)
	at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:61)
	at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:622)
	at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:82)
	at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1718)
	at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:379)
	at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
	at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:137)
	at org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:242)
	at org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.WrappedHibernateList.size(WrappedHibernateList.java:349)
	at org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl.writeCDOList(CDODataOutputImpl.java:402)
	at org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision.writeValues(BaseCDORevision.java:903)
	at org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision.write(BaseCDORevision.java:239)
	at org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl.writeCDORevision(CDODataOutputImpl.java:381)
	at org.eclipse.emf.cdo.spi.common.revision.RevisionInfo.writeRevision(RevisionInfo.java:221)
	at org.eclipse.emf.cdo.spi.common.revision.RevisionInfo.writeResult(RevisionInfo.java:159)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.LoadRevisionsIndication.responding(LoadRevisionsIndication.java:188)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndication.responding(CDOServerIndication.java:133)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:98)
	at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:298)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:67)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerReadIndication.execute(CDOServerReadIndication.java:36)



Thanks,
Rumburak
Re: [CDO] Enum serialization and second-level cache enabled [message #1114398 is a reply to message #1113646] Sun, 22 September 2013 17:38 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
If I got Martin right (from a previous issue), the hibernate second level cache is not supported at all in the HibernteStore as caching is handled by CDO itself.
Re: [CDO] Enum serialization and second-level cache enabled [message #1114507 is a reply to message #1114398] Sun, 22 September 2013 21:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
Hmm yes, indeed CDO also caches the revisions so the second level cache of hibernate is of less usage. But still the
issue reported by Rumburak seems quite solvable.

@Rumburak, can you enter a bugzilla for it?

gr. Martin

On 09/22/2013 07:38 PM, Erdal Karaca wrote:
> If I got Martin right (from a previous issue), the hibernate second level cache is not supported at all in the
> HibernteStore as caching is handled by CDO itself.


--

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] Enum serialization and second-level cache enabled [message #1114861 is a reply to message #1114507] Mon, 23 September 2013 10:09 Go to previous messageGo to next message
rumburak r is currently offline rumburak rFriend
Messages: 17
Registered: July 2011
Junior Member
Martin Taal wrote on Sun, 22 September 2013 17:19

Hmm yes, indeed CDO also caches the revisions so the second level cache of hibernate is of less usage. But still the issue reported by Rumburak seems quite solvable.
@Rumburak, can you enter a bugzilla for it?


done. https://bugs.eclipse.org/bugs/show_bug.cgi?id=417797

BTW I would like to know what is the status of the second-level cache in Hibernete Store. If the second level cache of hibernate is of less usage as Martin said, so it doesn't mean that is completely useless. But on the other hand I have not read any recommendations for use in CDO clinical Wink practice. Does the second-level cache increase the risk of certain types of drawbacks?

I asked you because I have noticed a performance improvement if I use the second-level cache in the Hibernete Store. I don't know what is the reason. The hibernate tutorial leads me to believe that the second-level cache improvements some fetch strategies (e.g. the recommended approach to problems with N+1 selects) but I still don't know what does this recommendation have to do with the Hibernete Store?

Thanks,
Rumburak
Re: [CDO] Enum serialization and second-level cache enabled [message #1114959 is a reply to message #1114861] Mon, 23 September 2013 13:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Rumburak,
Afaics there are no drawbacks of using the second level cache, but it is not widely used as cdo already caches. So you
can give it a serious try afaics. It can possibly help in certain cases as CDO will only cache what goes through its own
layers, while hibernate will also cache what passes through its layer (which maybe more as Hibernate also sometimes
loads additional objects).

gr. Martin

On 09/23/2013 12:09 PM, rumburak r wrote:
> Martin Taal wrote on Sun, 22 September 2013 17:19
>> Hmm yes, indeed CDO also caches the revisions so the second level cache of hibernate is of less usage. But still the
>> issue reported by Rumburak seems quite solvable.
>> @Rumburak, can you enter a bugzilla for it?
>
>
> done. https://bugs.eclipse.org/bugs/show_bug.cgi?id=417797
>
> BTW I would like to know what is the status of the second-level cache in Hibernete Store. If the second level cache of
> hibernate is of less usage as Martin said, so it doesn't mean that is completely useless. But on the other hand I have
> not read any recommendations for use in CDO clinical ;) practice. Does the second-level cache increase the risk of
> certain types of drawbacks?
>
> I asked you because I have noticed a performance improvement if I use the second-level cache in the Hibernete Store. I
> don't know what is the reason. The hibernate tutorial leads me to believe that the second-level cache improvements some
> fetch strategies (e.g. the recommended approach to problems with N+1 selects) but I still don't know what does this
> recommendation have to do with the Hibernete Store?
>
> Thanks,
> Rumburak


--

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] Enum serialization and second-level cache enabled [message #1115010 is a reply to message #1114959] Mon, 23 September 2013 14:25 Go to previous messageGo to next message
rumburak r is currently offline rumburak rFriend
Messages: 17
Registered: July 2011
Junior Member
Martin Taal wrote on Mon, 23 September 2013 09:17
Hi Rumburak,
Afaics there are no drawbacks of using the second level cache, but it is not widely used as cdo already caches. So you can give it a serious try afaics.


Thx Martin, I am going to test it further. The only thing that stopped it was this bug with Enums.
Rumburak
Re: [CDO] Enum serialization and second-level cache enabled [message #1115130 is a reply to message #1115010] Mon, 23 September 2013 17:57 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Rumburak,
Okay, btw where did you download the hibernate store plugins (I mean which version/timestamp are you using)?

gr. Martin

On 09/23/2013 04:25 PM, rumburak r wrote:
> Martin Taal wrote on Mon, 23 September 2013 09:17
>> Hi Rumburak,
>> Afaics there are no drawbacks of using the second level cache, but it is not widely used as cdo already caches. So you
>> can give it a serious try afaics.
>
>
> Thx Martin, I am going to test it further. The only thing that stopped it was this bug with Enums.
> Rumburak


--

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] Enum serialization and second-level cache enabled [message #1115512 is a reply to message #1115130] Tue, 24 September 2013 07:45 Go to previous messageGo to next message
rumburak r is currently offline rumburak rFriend
Messages: 17
Registered: July 2011
Junior Member
[quote title=Martin Taal wrote on Mon, 23 September 2013 13:57]Hi Rumburak,
Okay, btw where did you download the hibernate store plugins (I mean which version/timestamp are you using)?

Hi Martin,
I've tested several possibilities - AFAIR for my own model example I used the update site and the vesion 4.2.0.v20130601-1611, for the mango model test I used the version 4.2.0 from my git clone.

Rumburak
Re: [CDO] Enum serialization and second-level cache enabled [message #1115521 is a reply to message #1115512] Tue, 24 September 2013 07:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Rumburak,
Okay, I have worked the past weeks on performance improvements in the 4.2 stream also (so your git clone). See also this
update site:
http://www.eclipse.org/cdo/downloads/#maintenance

I wait until the SR1 release (beginning of next week) before working on/pushing new changes for the 4.2 stream.

Everything I do in 4.2.0 will also be in 4.3.0 ofcourse, will push/commit that sometime in october.

gr. Martin

On 09/24/2013 09:45 AM, rumburak r wrote:
> [quote title=Martin Taal wrote on Mon, 23 September 2013 13:57]Hi Rumburak,
> Okay, btw where did you download the hibernate store plugins (I mean which version/timestamp are you using)?
>
> Hi Martin,
> I've tested several possibilities - AFAIR for my own model example I used the update site and the vesion
> 4.2.0.v20130601-1611, for the mango model test I used the version 4.2.0 from my git clone.
>
> Rumburak
>


--

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] Enum serialization and second-level cache enabled [message #1115542 is a reply to message #1115521] Tue, 24 September 2013 08:32 Go to previous message
rumburak r is currently offline rumburak rFriend
Messages: 17
Registered: July 2011
Junior Member
Martin Taal wrote on Tue, 24 September 2013 03:59
Hi Rumburak,
Okay, I have worked the past weeks on performance improvements in the 4.2 stream also (so your git clone). See also this
update site:
http://www.eclipse.org/cdo/downloads/#maintenance

I wait until the SR1 release (beginning of next week) before working on/pushing new changes for the 4.2 stream.

Everything I do in 4.2.0 will also be in 4.3.0 ofcourse, will push/commit that sometime in october.

gr. Martin


Thank you for the info.
Rumburak
Previous Topic:[CDO] access CDO from &quot;outside&quot;
Next Topic:Generatin code from ecore models
Goto Forum:
  


Current Time: Thu Mar 28 15:13:43 GMT 2024

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

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

Back to the top