Quote:
Table 1
=====
C.id
name
street
....
....
....
Table 2 :
=====
B.Id
C.id
I suppose you creaeted entity classes for each table: Class1 for table1 and Class2 for table2. In Class2 there will be many-to-one association
@ManyToOne
@JoinColumn(name="c_id")
Class1 c.
Then you create query like this:
SELECT DISTINCT Class2.c FROM Class2 WHERE Class2.ID = 123 AND Class2.c.name = 'xyz'
I would like to write it more naturally, when c2 is one-to-many assosiated collection:
SELECT Class1 FROM Class1 WHERE Class1.name = 'xyz' AND Class1.c2.ID = 123
but this doesn't work - attemt do dereference collection. Does anyone know how make it work this way?