Hibernate version:
3.X
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="authentisoft.security.integration.model.RemoteRole" table="`REMOTEROLE`">
<composite-id>
<key-property name="directoryID" column="`ID`" type="long" />
<key-property name="name" column="`NAME`" type="string" />
</composite-id>
<!-- primitive mappings -->
<property name="active" column="`ACTIVE`" type="boolean" not-null="true" unique="false"/>
<property name="conception" column="`CONCEPTION`" type="timestamp" not-null="true"/>
<property name="lastModified" column="`LASTMODIFIED`" type="timestamp" not-null="true"/>
<property name="description" column="`DESCRIPTION`" type="string" not-null="false" />
<many-to-one name="directory" column="DIRECTORYID" class="authentisoft.security.model.directory.Directory"/>
<!-- object mappings -->
<map name="attributes" table="`REMOTEROLEATTRIBUTES`" cascade="all-delete-orphan">
<key>
<column name="`REMOTEROLEDIRECTORYID`"/>
<column name="`REMOTEROLENAME`"/>
</key>
<map-key column="`ATTRIBUTE`" type="string"/>
<many-to-many class="authentisoft.security.integration.model.AttributeValues" column="`ATTRIBUTEVALUESID`"/>
</map>
<set name="members" table="`REMOTEROLEMEMBERS`" cascade="none">
<key>
<column name="`REMOTEROLEDIRECTORYID`"/>
<column name="`REMOTEROLENAME`"/>
</key>
<many-to-many class="authentisoft.security.integration.model.RemotePrincipal">
<column name="`REMOTEPRINCIPALDIRECTORYID`"/>
<column name="`REMOTEPRINCIPALNAME`"/>
</many-to-many>
</set>
</class>
</hibernate-mapping>
Name and version of the database you are using:MySQL
Issue:13:05:20,328 DEBUG SQL: select this_.`ID` as ID1_1_, this_.`NAME` as NAME2_1_, this_.`ACTIVE` as ACTIVE3_21_1_, this_.`CONCEPTION` as CONCEPTION4_21_1_, this_.`LASTMODIFIED` as LASTMODI5_21_1_, this_.`DESCRIPTION` as DESCRIPT6_21_1_, this_.DIRECTORYID as DIRECTOR7_21_1_, members3_.`REMOTEROLEDIRECTORYID` as REMOTERO1___, members3_.`REMOTEROLENAME` as REMOTERO2___, remoteprin1_.`DIRECTORYID` as REMOTEPR3___, remoteprin1_.`NAME` as REMOTEPR4___, remoteprin1_.`DIRECTORYID` as DIRECTOR1_0_, remoteprin1_.`NAME` as NAME2_0_, remoteprin1_.`ACTIVE` as ACTIVE3_17_0_, remoteprin1_.`CONCEPTION` as CONCEPTION4_17_0_, remoteprin1_.`LASTMODIFIED` as LASTMODI5_17_0_ from `REMOTEROLE` this_ inner join `REMOTEROLEMEMBERS` members3_ on this_.`ID`=members3_.`REMOTEROLEDIRECTORYID` and this_.`NAME`=members3_.`REMOTEROLENAME` inner join `REMOTEPRINCIPAL` remoteprin1_ on members3_.`REMOTEPRINCIPALDIRECTORYID`=remoteprin1_.`DIRECTORYID` and members3_.`REMOTEPRINCIPALNAME`=remoteprin1_.`NAME` where this_.`ID`=? and remoteprin1_.`NAME`=? order by this_.`NAME` asc, this_.`ACTIVE` asc
13:05:20,343 DEBUG AbstractBatcher: preparing statement
13:05:20,359 DEBUG LongType: binding '1' to parameter: 1
13:05:20,359 DEBUG StringType: binding 'nstepka' to parameter: 2
13:05:20,359 DEBUG AbstractBatcher: about to open ResultSet (open ResultSets: 0, globally: 0)
Then when I run the SQL by hand:
select this_.`ID` as ID1_1_, this_.`NAME` as NAME2_1_, this_.`ACTIVE` as ACTIVE3_21_1_, this_.`CONCEPTION` as CONCEPTION4_21_1_, this_.`LASTMODIFIED` as LASTMODI5_21_1_, this_.`DESCRIPTION` as DESCRIPT6_21_1_, this_.DIRECTORYID as DIRECTOR7_21_1_, members3_.`REMOTEROLEDIRECTORYID` as REMOTERO1___, members3_.`REMOTEROLENAME` as REMOTERO2___, remoteprin1_.`DIRECTORYID` as REMOTEPR3___, remoteprin1_.`NAME` as REMOTEPR4___, remoteprin1_.`DIRECTORYID` as DIRECTOR1_0_, remoteprin1_.`NAME` as NAME2_0_, remoteprin1_.`ACTIVE` as ACTIVE3_17_0_, remoteprin1_.`CONCEPTION` as CONCEPTION4_17_0_, remoteprin1_.`LASTMODIFIED` as LASTMODI5_17_0_ from `REMOTEROLE` this_ inner join `REMOTEROLEMEMBERS` members3_ on this_.`ID`=members3_.`REMOTEROLEDIRECTORYID` and this_.`NAME`=members3_.`REMOTEROLENAME` inner join `REMOTEPRINCIPAL` remoteprin1_ on members3_.`REMOTEPRINCIPALDIRECTORYID`=remoteprin1_.`DIRECTORYID` and members3_.`REMOTEPRINCIPALNAME`=remoteprin1_.`NAME` where this_.`ID`=1 and remoteprin1_.`NAME`='nstepka' order by this_.`NAME` asc, this_.`ACTIVE` asc
ID1_1_ NAME2_1_ ACTIVE3_21_1_ CONCEPTION4_21_1_ LASTMODI5_21_1_ DESCRIPT6_21_1_ DIRECTOR7_21_1_ REMOTERO1___ REMOTERO2___ REMOTEPR3___ REMOTEPR4___ DIRECTOR1_0_ NAME2_0_ ACTIVE3_17_0_ CONCEPTION4_17_0_ LASTMODI5_17_0_
--------- ----------- ---------------- --------------------- --------------------- ------------------ ------------------ --------------- --------------- --------------- --------------- --------------- ----------- ---------------- --------------------- ---------------------
1 Role1 1 2005-07-31 12:42:22.0 2005-07-31 12:42:22.0 Role1 Description 1 1 Role1 1 nstepka 1 nstepka 1 2005-07-31 12:41:12.0 2005-07-31 12:43:25.0
1 record(s) selected [Fetch MetaData: 31/ms] [Fetch Data: 47/ms]
[Executed: 7/31/05 12:57:22 PM CDT ] [Execution: 0/ms]
Hibernate criteria query:
Criteria criteria = HibernateHelper.getSession().createCriteria(RemoteRole.class);
criteria.createCriteria("members").add(Expression.eq("name", searchContext.get(SearchContext.ROLE_PRINCIPAL_MEMBER).toString()));
criteria.addOrder(Order.asc("name"));
criteria.addOrder(Order.asc("active"));[/code]
The issue is that the runtime is returning no results, but querying by hand is finding the results I am looking for...