Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Persistence: Hibernate exceptions

Hi,
I'm using Hibernate persistence with GS (write-through / sync / direct mode). I need to persist only a subset of space classes on which I have set "@SpaceClass(persist = true)" along with other hibernate/JPA annotations. On the other hand for the classes which are not required to be persisted, I have "@SpaceClass(persist = false)".


This is all good until my application starts using SQLQuery based GS APIs. For example template based readMultiple() works fine whereas Query based readMultiple() fails with the exception given below.

So here are my questions:

  1. Once I have set persist=false on the class, why is Hibernate getting involved?
  2. I have tried setting query parameters explicitly by index - both starting at 0 as well as 1 (I believe 1 to be correct start index). This doesn't help. Is there a specific way to use query based APIs on persistent space?

Additional details:

  • I'm using GS 9.7
  • Attached is my POJO
  • Attached is my pu config
  • Here is the code to query

    final SQLQuery<handleentry> query = new SQLQuery<handleentry>(HandleEntry.class, "handle = ? or (handle = ? and domainId = ?)") .setParameter(1, handleName) .setParameter(2, userPart) .setParameter(3, domainId);

    gs.readMultiple(query);

Exception:

Caused by: java.sql.SQLException: Select failed; Cause: java.sql.SQLException: Failed to execute readMultiple: com.gigaspaces.client.ReadMultipleException: Success:1, errors:1, [class org.hibernate.QueryParameterException:1
StackTrace: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1
        at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:81)
        at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:87)
        at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:444)
        at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:416)
        at org.openspaces.persistency.hibernate.iterator.HibernateIteratorUtils.createQueryFromDataSourceSQLQuery(HibernateIteratorUtils.java:73)
        at org.openspaces.persistency.hibernate.iterator.DefaultListQueryDataIterator.createIterator(DefaultListQueryDataIterator.java:154)
        at org.openspaces.persistency.hibernate.iterator.DefaultListQueryDataIterator.hasNext(DefaultListQueryDataIterator.java:106)
        at org.openspaces.persistency.hibernate.iterator.HibernateProxyRemoverIterator.hasNext(HibernateProxyRemoverIterator.java:53)
        at com.gigaspaces.datasource.concurrentaccess.SharedDataIteratorSource.waitForNext(SharedDataIteratorSource.java:225)
        at com.gigaspaces.datasource.concurrentaccess.SharedDataIterator.hasNext(SharedDataIterator.java:41)
        at com.j_spaces.sadapter.datasource.EntryAdapterIterator.hasNext(EntryAdapterIterator.java:60)
        at com.j_spaces.sadapter.datasource.DataAdaptorIterator._hasNext(DataAdaptorIterator.java:98)
        at com.j_spaces.sadapter.datasource.DataAdaptorIterator.next(DataAdaptorIterator.java:124)
        at com.j_spaces.sadapter.datasource.DataAdaptorIterator.next(DataAdaptorIterator.java:33)
        at com.j_spaces.core.cache.EntriesIter.saIterNext(EntriesIter.java:459)
        at com.j_spaces.core.cache.EntriesIter.next(EntriesIter.java:191)
        at com.j_spaces.core.cache.EntriesIter.next(EntriesIter.java:33)
        at com.j_spaces.core.cache.ScanListSAIterator.hasNext(ScanListSAIterator.java:48)
        at com.gigaspaces.internal.server.space.SpaceEngine.getMatchedEntriesAndOperateSA_Scan(SpaceEngine.java:4296)
        at com.gigaspaces.internal.server.space.SpaceEngine.executeOnMatchingEntries(SpaceEngine.java:4238)
        at com.j_spaces.core.server.processor.Processor.executeBatchSearchAndProcessing(Processor.java:2817)
        at com.j_spaces.core.server.processor.Processor.handleDirectMultipleReadTakeSA(Processor.java:2612)
        at com.gigaspaces.internal.server.space.SpaceEngine.readMultiple(SpaceEngine.java:1960)
        at com.gigaspaces.internal.server.space.SpaceImpl.readMultiple(SpaceImpl.java:2261)
        at com.gigaspaces.internal.server.space.operations.ReadTakeEntriesSpaceOperation.execute(ReadTakeEntriesSpaceOperation.java:31)
        at com.gigaspaces.internal.server.space.operations.ReadTakeEntriesSpaceOperation.execute(ReadTakeEntriesSpaceOperation.java:21)
        at com.gigaspaces.internal.server.space.operations.SpaceOperationsExecutor.executeOperation(SpaceOperationsExecutor.java:77)
        at com.gigaspaces.internal.server.space.SpaceImpl.executeOperation(SpaceImpl.java:1832)
        at com.gigaspaces.internal.server.space.SpaceImpl.executeOperationAsync(SpaceImpl.java:1839)
        at com.gigaspaces.internal.remoting.RemoteOperationsExecutorGigaspacesMethodinternalInvoke2.internalInvoke(Unknown Source)
        at com.gigaspaces.internal.reflection.fast.AbstractMethod.invoke(AbstractMethod.java:41)
        at com.gigaspaces.lrmi.LRMIRuntime.invoked(LRMIRuntime.java:464)
        at com.gigaspaces.lrmi.nio.Pivot.consumeAndHandleRequest(Pivot.java:561)
        at com.gigaspaces.lrmi.nio.Pivot.handleRequest(Pivot.java:662)
        at com.gigaspaces.lrmi.nio.Pivot$ChannelEntryTask.run(Pivot.java:196)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

gs-prob.zip gsPersistenceSync.zip

asked 2014-07-29 15:26:52 -0500

myth's avatar

updated 2014-08-07 14:05:19 -0500

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

Hi Yuval,

I did attach the original entry class and the pu configuration. Currently I don't have the corresponding client code. So I reproduced the problem in another sample project which I'm attaching here. The client code is in Main.java. Please look for the comment "PROBLEM CODE" in there.

Please let me know if you need any further info.

Thanks,

Chetan

gsPersistenceSync.zip

answered 2014-08-07 13:56:50 -0500

myth's avatar

updated 2014-08-07 14:05:38 -0500

edit flag offensive delete link more
0

Hi,

Please attach the class where you write the following code: final SQLQuery<handleentry> query = new SQLQuery<handleentry>(HandleEntry.class, "handle = ? or (handle = ? and domainId = ?)") .setParameter(1, handleName) .setParameter(2, userPart) .setParameter(3, domainId); gs.readMultiple(query);

Is there a chance that you use: org.hibernate.SQLQuery instead of: com.j_spaces.core.client.SQLQuery

Regards,

Yuval

answered 2014-08-07 08:58:11 -0500

Yuval's avatar
edit flag offensive delete link more
0

Hi,

We found that this is indeed a problem. It will be fixed in the next version.

Regards,

Yuval

answered 2014-08-11 08:08:22 -0500

Yuval's avatar
edit flag offensive delete link more

Comments

Thanks for confirming that. Is there a way to track this problem and the fix?

myth's avatar myth  ( 2014-08-11 09:07:44 -0500 )edit

Hi Chetan,

We are going to fix it in 10.1 version which will issue in a few months and also working on a patch over 9.7.1. This patch should be available in a few days.

Regards,

Yuval

Yuval's avatar Yuval  ( 2014-08-11 09:40:44 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-07-29 15:26:52 -0500

Seen: 677 times

Last updated: Aug 11 '14