Tu je criteria, ktore pouzivam>
DetachedCriteria.forClass(CardReaderAppKey.class)
.add(Restrictions.eq("cardReader",
new CardReader(aCardReaderId)))
.add(Restrictions.eq("appKeyId",
aAppKeyId))
.add(Restrictions.eq("appId",
aAppId))
.createCriteria("applicationKey").addOrder(Order.desc("validFrom"));
2007/8/21, Lukas Barton <[EMAIL PROTECTED]>:
>
> Jake je vase HQL/Criteria?
>
> Lukas
>
> Dušan Mamrilla wrote:
>
> Bohuzial to nepomohlo.
>
> Log zaznam so selektom:
>
> DEBUG SQL -
> select
> this_.token_id as token1_4_1_,
> this_.app_id as app2_4_1_,
> this_.appkey_id as appkey3_4_1_,
> this_.cr_id as cr4_4_1_,
> this_.key_id as key5_4_1_,
> this_.confirmed as confirmed4_1_,
> applicatio1_.token_id as token1_3_0_,
> applicatio1_.app_id as app2_3_0_,
> applicatio1_.appkey_id as appkey3_3_0_,
> applicatio1_.key_id as key4_3_0_,
> applicatio1_.valid_from as valid5_3_0_
> from
> test.hsm_cardreader_appkey this_
> inner join
> test.hsm_appkey applicatio1_
> on this_.token_id=applicatio1_.token_id
> and this_.app_id=applicatio1_.app_id
> and this_.appkey_id=applicatio1_.appkey_id
> and this_.key_id=applicatio1_.key_id
> where
> this_.cr_id=?
> and this_.appkey_id=?
> and this_.app_id=?
> order by
> applicatio1_.valid_from desc
> DEBUG AbstractBatcher - preparing statement
> DEBUG IdentifierValue - id unsaved-value strategy UNDEFINED
> DEBUG LongType - binding '14031980' to parameter: 1
> DEBUG IntegerType - binding '2' to parameter: 2
> DEBUG StringType - binding 'KUTEST' to parameter: 3
> DEBUG AbstractBatcher - about to open ResultSet (open ResultSets: 0,
> globally: 0)
> DEBUG Loader - processing result set
> DEBUG Loader - result set row: 0
> DEBUG IntegerType - returning '0' as column: token1_3_0_
> DEBUG StringType - returning 'KUTEST' as column: app2_3_0_
> DEBUG IntegerType - returning '2' as column: appkey3_3_0_
> DEBUG StringType - returning 'KEY_2' as column: key4_3_0_
> DEBUG IntegerType - returning '0' as column: token1_4_1_
> DEBUG StringType - returning 'KUTEST' as column: app2_4_1_
> DEBUG IntegerType - returning '2' as column: appkey3_4_1_
> DEBUG LongType - returning '14031980' as column: cr4_4_1_
> DEBUG DefaultLoadEventListener - loading entity: [
> sk.prosoft.hsm.pojo.CardReader#14031980]
> DEBUG DefaultLoadEventListener - entity found in session cache
> DEBUG Loader - result row: EntityKey[
> sk.prosoft.hsm.pojo.ApplicationKey#component[tokenId,appId,appKeyId,keyId]{appId=KUTEST,
> tokenId=0, appKeyId=2, keyId=KEY_2}], EntityKey[
> sk.prosoft.hsm.pojo.CardReaderAppKey#component[tokenId,appId,appKeyId,cardReader]{appId=KUTEST,
> tokenId=0, cardReader=
> sk.prosoft.hsm.pojo.CardReader#14031980, appKeyId=2}]
> DEBUG Loader - done processing result set (1 rows)
>
>
> 2007/8/21, Lukas Barton <[EMAIL PROTECTED]>:
> >
> > Jake SQL vam to generuje pro nacteni te relace?
> > Pokud si dobre pamatuji je Hibernate citlivy na poradi sloupcu v
> > many-to-one, zkuste prohodit key_id a appkey_id.
> >
> > Lukas
> >
> > Dušan Mamrilla wrote:
> >
> > Zdravim,
> >
> > Mam problem s vysledkom mapovania jednosmernej one-to-one asociacie.
> > Priklad mapovania:
> >
> > <class name="CardReaderAppKey" table="hsm_cardreader_appkey">
> > <composite-id>
> > <key-property name="tokenId" column="token_id"/>
> > <key-property name="appId" column="app_id"/>
> > <key-property name="appKeyId" column="appkey_id"/>
> > <key-many-to-one name="cardReader" class="CardReader"
> > column="cr_id"/>
> > </composite-id>
> > <property name="keyId" column="key_id" not-null="true"/>
> > <property name="confirmed"/>
> > <many-to-one name="applicationKey" class="ApplicationKey"
> > insert="false" update="false" unique="true" not-null="true">
> > <column name="token_id"/>
> > <column name="app_id"/>
> > <column name="key_id"/>
> > <column name="appkey_id"/>
> > </many-to-one>
> > </class>
> >
> >
> > Problem nastava pri listovani [ list() hibernate metoda] objektov
> > CardReaderAppKey. Vratene objekty nemaju nainicializovanu vlastnost
> > applicationKey napriek tomu, ze z databazy su tieto objekty fetchnute (
> > vycitane z hibernate logu). Ocakaval by som ze bude nastavene cglib proxy.
> > pouzivam hibernate 3.2.3.GA, java6, spring 2.0.6, cglib-nodep.2.1_3.
> > Fetch a lazy su nastavene na defaultne hodnoty.
> >
> > Googlil som, skusal som a nepomohlo :| . Hadam ma niekto z vas nakopne
> > spravnym smerom.
> >
> > Dik.
> >
> >
> >
>
>