Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » fetch multi-level relations
fetch multi-level relations [message #388104] Thu, 21 May 2009 14:57 Go to next message
Yolanda is currently offline Yolanda
Messages: 5
Registered: July 2009
Junior Member
Hello.
When I need to fetch multi-level relations of an entity I always do it
this way:

Query q = entityManager.createQuery("SELECT o FROM Gddist o WHERE
o.dist1cod IN (SELECT a.dist2cod.dist1cod FROM Gdalba a WHERE a.gdalbaPK =
:qGdalbaPK)");

ReadAllQuery query = (ReadAllQuery)((JpaQuery)q).getDatabaseQuery();
Expression ex = query.getExpressionBuilder();
query.addJoinedAttribute(ex.getAllowingNull("gdpobl"));
query.addJoinedAttribute(ex.getAllowingNull("gdpobl").getAllowingNull( "gdprov"));
q.setParameter("qGdalbaPK", gdalbaPK);

It always works well. But in this case I get an exception.
What am I doing wrong?

Thanks for your help:
Yolanda

This is the exception:

java.lang.IllegalArgumentException: fromIndex(29) > toIndex(19)
at
org.eclipse.persistence.internal.helper.NonSynchronizedSubVe ctor. <init>(NonSynchronizedSubVector.java:32)
at
org.eclipse.persistence.mappings.ForeignReferenceMapping.tri mRowForJoin(ForeignReferenceMapping.java:1462)
at
org.eclipse.persistence.mappings.ForeignReferenceMapping.tri mRowForJoin(ForeignReferenceMapping.java:1434)
at
org.eclipse.persistence.mappings.OneToOneMapping.valueFromRo wInternalWithJoin(OneToOneMapping.java:992)
at
org.eclipse.persistence.mappings.ForeignReferenceMapping.val ueFromRow(ForeignReferenceMapping.java:1338)
at
org.eclipse.persistence.mappings.DatabaseMapping.readFromRow IntoObject(DatabaseMapping.java:1119)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildAttributesIntoObject(ObjectBuilder.java:301)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:625)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:463)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:413)
at
org.eclipse.persistence.mappings.OneToOneMapping.valueFromRo wInternalWithJoin(OneToOneMapping.java:1004)
at
org.eclipse.persistence.mappings.ForeignReferenceMapping.val ueFromRow(ForeignReferenceMapping.java:1338)
at
org.eclipse.persistence.mappings.DatabaseMapping.readFromRow IntoObject(DatabaseMapping.java:1119)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildAttributesIntoObject(ObjectBuilder.java:301)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:625)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildWorkingCopyCloneNormally(ObjectBuilder.java:547)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObjectInUnitOfWork(ObjectBuilder.java:517)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:461)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildObject(ObjectBuilder.java:413)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.buildOb ject(ObjectLevelReadQuery.java:521)
at
org.eclipse.persistence.queries.ReadAllQuery.registerResultI nUnitOfWork(ReadAllQuery.java:893)
at
org.eclipse.persistence.queries.ReadAllQuery.executeObjectLe velReadQuery(ReadAllQuery.java:486)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute DatabaseQuery(ObjectLevelReadQuery.java:879)
at
org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:666)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute (ObjectLevelReadQuery.java:840)
at
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAll Query.java:456)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute InUnitOfWork(ObjectLevelReadQuery.java:902)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2587)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1178)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1162)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1136)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1118)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeRea dQuery(EJBQueryImpl.java:399)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleR esult(EJBQueryImpl.java:547)
at
com.adiante.sidi.model.sidifacade.ejb.actions.ObtenerGddistP orGdalbaPKAction.execute(ObtenerGddistPorGdalbaPKAction.java :63)
at
com.adiante.sidi.model.sidifacade.ejb.actions.ObtenerGddistP orGdalbaPKAction.execute(ObtenerGddistPorGdalbaPKAction.java :29)
at
com.adiante.orr.j2ee.utils.ejb.ActionProcessor.process(Actio nProcessor.java:35)
at
com.adiante.sidi.model.sidifacade.ejb.SidiFacadeEJB.obtenerG ddistPorGdalbaPK(SidiFacadeEJB.java:5338)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointIm pl.invoke(EJBJoinPointImpl.java:35)
at
com.evermind.server.ejb.interceptor.InvocationContextImpl.pr oceed(InvocationContextImpl.java:119)
at
com.evermind.server.ejb.interceptor.system.SetContextActionI nterceptor.invoke(SetContextActionInterceptor.java:44)
at
com.evermind.server.ejb.interceptor.InvocationContextImpl.pr oceed(InvocationContextImpl.java:119)
at
com.evermind.server.ejb.interceptor.system.DMSInterceptor.in voke(DMSInterceptor.java:52)
at
com.evermind.server.ejb.interceptor.InvocationContextImpl.pr oceed(InvocationContextImpl.java:119)
at
com.evermind.server.ejb.interceptor.system.TxRequiredInterce ptor.invoke(TxRequiredInterceptor.java:50)
at
com.evermind.server.ejb.interceptor.InvocationContextImpl.pr oceed(InvocationContextImpl.java:119)
at
com.evermind.server.ejb.interceptor.system.DMSInterceptor.in voke(DMSInterceptor.java:52)
at
com.evermind.server.ejb.interceptor.InvocationContextImpl.pr oceed(InvocationContextImpl.java:119)
at
com.evermind.server.ejb.InvocationContextPool.invoke(Invocat ionContextPool.java:55)
at
com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invok eMethod(StatelessSessionEJBObject.java:87)
at SidiFacadeEJB_RemoteProxy_l85a14.obtenerGddistPorGdalbaPK(Un known
Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java :53)
at
com.evermind.util.ReleasableResourcePooledExecutor$MyWorker. run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619)
Re: fetch multi-level relations [message #388117 is a reply to message #388104] Mon, 25 May 2009 17:33 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This is odd. You might want to try using the query hint instead, but if
your code is working in some cases, then it is probably valid.

What is different about this query than your queries that worked? Can you
try to narrow down what the different in the query or object model is. Is
the class involved in inheritance? Please include your mappings.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: fetch multi-level relations [message #389704 is a reply to message #388117] Mon, 22 June 2009 11:00 Go to previous message
Yolanda is currently offline Yolanda
Messages: 5
Registered: July 2009
Junior Member
Hi James.
Sorry, I couldn't reply earlier.
I resolve this using eclipselink 1.1.1
Thanks for all.
Previous Topic:Diffrence of parameter format
Next Topic:Transactions
Goto Forum:
  


Current Time: Mon Sep 22 12:14:04 GMT 2014

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

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