Bohuzel toto mi nefunguje a vyhodi mi vyjimku:

org.hibernate.QueryException: could not resolve property: entA.text of:
Entita2

property je namapovana jako:

<hibernate-mapping>
 <class dynamic-update="true" table="ent2_table" name="Ent2"
dynamic-insert="true">
   <id type="long" column="id" name="id">
     <generator class="native"/>
   </id>
   <many-to-one not-null="true" insert="true" column="entA"
foreign-key="fk_entA" update="true" cascade="none" name="entA"
class="Ent1"/>
<many-to-one not-null="true" insert="true" column="entB"
foreign-key="fk_entB" update="true" cascade="none" name="entB"
class="Ent1"/>

   <property name="text" insert="true" not-null="true" type="string"
column="text" update="true"/>
   </class>
</hibernate-mapping>

Jaroslav Hurdes

Pavel (Michal) Pavlasek napsal(a):
mozno som to nepochopil, ale nie je to obycajny or?
crit.add(Restrictions.or(
                   Restrictions.eq(entA.text, "blaaaa"),
                   Restrictions.eq(entB.text, "blaaaa")));

+asi pozrite v dokumentacii ako sa robia aliasy, ak chcete "nested" properties
metoda createAlias v Criteria, ak sa dobre pamatam.

s pozdravom
CoPLaS

Jaroslav Hurdes  wrote / napĂ­sal(a):
Zdravim vsechny. Mam nasledujici entity kde Entita2 obsahuje dve reference na Entitu1 spojenou pres id.

Entita1 {
   Long id;
   String text;
}

Entita2 {
   Long id;
   String text;
   Entita1 entA;
   Entita1 entB;
}


Chtel bych vytvorit dotaz pomoci kriterii, ktery by mel za cil nacist Entity2 podle podminky napr:

text = '?' and (entA.text = ? or entB.text = ?)

Jde mi o to, ze se mi nedari prijit na to jak pomoci kriterii vytvorit ten OR mezi hodnotou textu entA a hodnotou textu entB.

Dekuji Jaroslav Hurdes



Odpovedet emailem