You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Jakob Braeuchi <jb...@gmx.ch> on 2004/03/04 20:27:20 UTC
Re: JOIN and aliases...is this a bug?
hi alessandro,
according to your repository db.DBAttribute contains a field called 'nname'
<field-descriptor
name="nname"
column="NAME"
primarykey="true"
jdbc-type="VARCHAR"
/>
there's no field called 'name'. so you can either change your repository or
adapt your query:
Criteria c = new Criteria();
c.addEqualsTo("attributes.nname", "Ale");
Query q = QueryFactory.newQuery(DBObject.class, c);
jakob
Alessandro Villamaina wrote:
> Hi Jackob,
> this is the class descriptor I currently use.
> Thanks for help!
>
> Alessandro
>
> <class-descriptor class="db.DBObject" table="DBOBJECT">
>
> <field-descriptor
> name="name"
> column="NAME"
> jdbc-type="VARCHAR"
> primarykey="true"
> />
>
> <collection-descriptor
> name="attributes"
> auto-delete="true"
> auto-update="true"
> element-class-ref = "db.DBAttribute">
> <inverse-foreignkey field-ref = "owner" />
> </collection-descriptor>
>
> </class-descriptor>
>
> <class-descriptor
> class="db.DBAttribute"
> table="DBATTRIBUTE">
>
> <field-descriptor
> name="nname"
> column="NAME"
> primarykey="true"
> jdbc-type="VARCHAR"
> />
>
> <field-descriptor
> name="vvalue"
> column="VALUE"
> jdbc-type="VARCHAR"
> />
>
> <field-descriptor
> name="owner"
> column="OWNER"
> jdbc-type="VARCHAR"
> primarykey="true"
> access="anonymous"
> />
> </class-descriptor>
>
>>Da: Jakob Braeuchi <jb...@gmx.ch>
>>Data: Fri, 20 Feb 2004 21:57:23 +0100
>>A: OJB Users List <oj...@db.apache.org>
>>Oggetto: Re: JOIN and aliases...is this a bug?
>>
>>hi alessandro,
>>
>>could you please post the class-descriptors ?
>>
>>jakob
>>
>>Alessandro Villamaina wrote:
>>
>>
>>>Hi all,
>>>
>>>I have the following class declaration (pseudo code):
>>>
>>>class DBObject
>>> private String name
>>> private Collection attributes
>>>
>>>class DBAttribute
>>> private String name
>>> private String value
>>>
>>>when I execute a query like the following (with PB API):
>>>
>>>Criteria c = new Criteria();
>>>c.addEqualsTo("attributes.name", "Ale");
>>>Query q = QueryFactory.newQuery(DBObject.class, c);
>>>
>>>the generated SQL statement is
>>>
>>>SELECT A0.NAME FROM DBOBJECT A0 JOIN DBATTRIBUTE A1 ON A0.NAME=A1.OWNER WHERE name = 'Ale';
>>>
>>>where OWNER is the column used by OJB to maintain references between an object and its attributes as specified in the repository_user.xml.
>>>
>>>It seems OJB "forgets" to use the alias A1 to qualify the attribute name in the WHERE clause; since both tables have such attribute, the query fails (using name instead of A1.name is ambiguous).
>>>
>>>Is this a bug in OJB or am I doing something wrong?
>>>Thanks,
>>>
>>>Alessandro
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org