Re: Join tables that has fields with same name

2003-09-10 Thread Jakob Braeuchi
hi istvan,

this looks like a problem in your mapping. if ojb finds descriptors for 
the fields it prefixes them with a table alias (a.name).
if no field is found the name from the criteria is used.

hth
jakob
Viczin Istvn wrote:

Hi,

I would like to join two table, and they are in 1:n relation, and they have
a field with same name. If
I add a criteria to this, I get an exception. This exception says,
that the field is _ambiguous_.
I've logged the SQL query with P6Spy, and it is true, the name of the field
appears in the select statement without qualification, so the name of the
field is
really ambiguous. I've tried qualify with the table name, but it is not
good, it should be
qualified with the alias.
Concretely symbolically:
table A (a_id, samename);
table B (b_id, a_id, samename, prop);
A:B = 1:N

Criteria c1; c.addEquals(samename, blahblah); // criteria for the
Criteria c1; c.addEquals(b.prop, 1); // join
Query for table A, request for A objects
So the exception says, that the samename is ambiguous.
The generated sql is something like this:
select a_id, samename from A a0 INNER JOIN B a1 WHERE samename = 'blahblah'
and
a0.a_id = a1.b_id and a1.prop = 1;
So the samename field appears without alias qualification.
How should I correct my code without renaming columns to individual name?
Thank you,

	Istvan

---
Viczin Istvn [Viczi] ([EMAIL PROTECTED])
Honlap: http://dragon.unideb.hu/~vicziani
Mobil#: +36(30)3656804 ICQ#: 15803584
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Join tables that has fields with same name

2003-09-09 Thread Viczin Istvn
Hi,

I would like to join two table, and they are in 1:n relation, and they have
a field with same name. If
I add a criteria to this, I get an exception. This exception says,
that the field is _ambiguous_.
I've logged the SQL query with P6Spy, and it is true, the name of the field
appears in the select statement without qualification, so the name of the
field is
really ambiguous. I've tried qualify with the table name, but it is not
good, it should be
qualified with the alias.

Concretely symbolically:
table A (a_id, samename);
table B (b_id, a_id, samename, prop);

A:B = 1:N

Criteria c1; c.addEquals(samename, blahblah); // criteria for the
Criteria c1; c.addEquals(b.prop, 1); // join
Query for table A, request for A objects

So the exception says, that the samename is ambiguous.
The generated sql is something like this:

select a_id, samename from A a0 INNER JOIN B a1 WHERE samename = 'blahblah'
and
a0.a_id = a1.b_id and a1.prop = 1;

So the samename field appears without alias qualification.
How should I correct my code without renaming columns to individual name?

Thank you,

Istvan

---
Viczin Istvn [Viczi] ([EMAIL PROTECTED])
Honlap: http://dragon.unideb.hu/~vicziani
Mobil#: +36(30)3656804 ICQ#: 15803584


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]