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 Alessandro Villamaina <av...@etnoteam.it> on 2004/02/19 14:58:42 UTC

JOIN and aliases...is this a bug?

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


Re: JOIN and aliases...is this a bug?

Posted by Jakob Braeuchi <jb...@gmx.ch>.
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