geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "D. Strauss" <geron...@ds-2.de>
Subject Re: ejbQL with relations
Date Wed, 12 Jul 2006 14:29:45 GMT
Hello, Aaron,

after re-reading your answer I came up with a strange idea. After some
research and testing I can finally say: I was wrong ^^;;;;

My ejbQL was

select distinct object(g) from Guild as g, in (g.realm) as r order by
r.realmName asc

But I learned a wrong ejbQL: the IN statement is for a collection. So,
you were right: realm IS NOT a collection but a simple lonely cmr field
that references another entity. I always thought that IN() is for
reading from a related bean (think of IN as an additional load).

So, sorry for spamming the ML with this ^^;;;; my bad.

For the curious people: the working ejbQL is:

select distinct object(g) from Guild as g order by g.realm.realmName asc

Best regards

Dirk

D. Strauss schrieb:
> Hello, Aaron
> 
> seems that my "workaround" failed. As soon as a relation column is used
> within a finder ejbQL TranQL gives up ... or better said: it seems that
> it gives up. Here a nice stack trace that emphasizes my problem:
> 
> Caused by: org.tranql.ql.QueryException: Finder [Finder
> method=[findAll]; EJB-QL=[select distinct object(g) from Guild as g, in
> (g.realm) as r order by g.guildName asc, r.realmName asc]]
>         at
> org.tranql.sql.EJBQLToPhysicalQuery.buildFinder(EJBQLToPhysicalQuery.java:143)
>         at
> org.tranql.sql.EJBQLToPhysicalQuery.buildFinders(EJBQLToPhysicalQuery.java:90)
>         ... 36 more
> Caused by: org.tranql.ql.QueryException: Parser, lexer or Tree-walker
> exception
>         at
> org.tranql.sql.EJBQLToPhysicalQuery.getEJBQLQuery(EJBQLToPhysicalQuery.java:235)
>         at
> org.tranql.sql.EJBQLToPhysicalQuery.buildFinder(EJBQLToPhysicalQuery.java:130)
>         ... 37 more
> Caused by: org.tranql.ql.MalformedNodeException: Path used must end with
> a multi valued CMR field
>         at org.tranql.ql.DerivedTable.getEntityType(DerivedTable.java:61)
>         at org.tranql.ql.DerivedTable.<init>(DerivedTable.java:36)
>         at
> org.tranql.ejb.parser.EJBQL21Compiler.collection_member_declaration(EJBQL21Compiler.java:473)
>         at
> org.tranql.ejb.parser.EJBQL21Compiler.from_clause(EJBQL21Compiler.java:201)
>         at
> org.tranql.ejb.parser.EJBQL21Compiler.ejbql(EJBQL21Compiler.java:115)
>         at
> org.tranql.sql.EJBQLToPhysicalQuery.getEJBQLQuery(EJBQLToPhysicalQuery.java:233)
>         ... 38 more
> 
> So, it is a TranQL problem? Should I post this to the TranQL ML?
> 
> Oh, before I forgot:
> 
> Guild n:1 Realm
> 
> (1 Realm can have multiple guilds, but 1 guild can only belong to 1
> Realm, so 1:n relation).
> 
> My openejb-jar.xml for the relation looks like:
> 
> <ejb-relation>
> 	<ejb-relation-name>relGuildRealm</ejb-relation-name>
> 	<ejb-relationship-role>
> 		<ejb-relationship-role-name>
> 			r1
> 		</ejb-relationship-role-name>
> 		<relationship-role-source>
> 			<ejb-name>Guild</ejb-name>
> 		</relationship-role-source>
> 		<cmr-field>
> 			<cmr-field-name>realm</cmr-field-name>
> 		</cmr-field>
> 		<foreign-key-column-on-source />
> 		<role-mapping>
> 			<cmr-field-mapping>
> 				<key-column>id</key-column>
> 				<foreign-key-column>
> 					refrealm
> 				</foreign-key-column>
> 			</cmr-field-mapping>
> 		</role-mapping>
> 	</ejb-relationship-role>
> </ejb-relation>
> 
> Let me know if you need more information.
> 
> Best regards
> 
> Dirk
> 
> Aaron Mulder schrieb:
>> My guess would be that r.partei refers to a single entity (as in a
>> 1-to-1 relationship between r and p) but the "in" operator expects its
>> argument to be a group or set (as in a 1-to-many) relationship.  Does
>> that sound right?
>>
>> Thanks,
>>    Aaron
>>
>> On 7/7/06, D. Strauss <geronimo@ds-2.de> wrote:
>>> Hello, ejbQL profs ^^
>>>
>>> seems that I missunderstood my ejbQL knowledge. I setup some ejbs and
>>> wanted to create some finder methods (ejb-jar.xml). Unfortunately,
>>> Geronimo (or OpenEJB?) ends in an exception that I can't figure out what
>>> it wants to tell me.
>>>
>>>
>>>
>>> Caused by: org.tranql.ql.QueryException: Finder [Finder
>>> method=[findAll]; EJB-QL=[select distinct object(r) from Rasse as r, in
>>> (r.partei) as p order by p.parteiName asc,r.rassenName asc]]
>>>         at
>>> org.tranql.sql.EJBQLToPhysicalQuery.buildFinder(EJBQLToPhysicalQuery.java:143)
>>>
>>>         at
>>> org.tranql.sql.EJBQLToPhysicalQuery.buildFinders(EJBQLToPhysicalQuery.java:90)
>>>
>>>         ... 36 more
>>> Caused by: org.tranql.ql.QueryException: Parser, lexer or Tree-walker
>>> exception
>>>         at
>>> org.tranql.sql.EJBQLToPhysicalQuery.getEJBQLQuery(EJBQLToPhysicalQuery.java:235)
>>>
>>>         at
>>> org.tranql.sql.EJBQLToPhysicalQuery.buildFinder(EJBQLToPhysicalQuery.java:130)
>>>
>>>         ... 37 more
>>> Caused by: org.tranql.ql.MalformedNodeException: Path used must end with
>>> a multi valued CMR field
>>>         at org.tranql.ql.DerivedTable.getEntityType(DerivedTable.java:61)
>>>         at org.tranql.ql.DerivedTable.<init>(DerivedTable.java:36)
>>>         at
>>> org.tranql.ejb.parser.EJBQL21Compiler.collection_member_declaration(EJBQL21Compiler.java:473)
>>>
>>>         at
>>> org.tranql.ejb.parser.EJBQL21Compiler.from_clause(EJBQL21Compiler.java:201)
>>>
>>>         at
>>> org.tranql.ejb.parser.EJBQL21Compiler.ejbql(EJBQL21Compiler.java:115)
>>>         at
>>> org.tranql.sql.EJBQLToPhysicalQuery.getEJBQLQuery(EJBQLToPhysicalQuery.java:233)
>>>
>>>         ... 38 more
>>>
>>>
>>> So, basically, the ejbQL
>>>         select distinct object(r) from Rasse as r, in (r.partei) as p
>>> order by
>>> p.parteiName asc,r.rassenName asc
>>> is wrong. However, the ejbQL
>>>         select distinct object(r) from Rasse as r order by
>>> r.rassenName asc
>>> works.
>>>
>>> Does anyone know what "Path used must end with a multi valued CMR field"
>>> mean?
>>>
>>> Or is this somehow related to the prefetch system by Geronimo?
>>>
>>> Best regards
>>>
>>> Dirk
>>>
>>
> 
> 

Mime
View raw message