Hibernate version:
3.0.5
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="vitalvinyl.model.item.Item" table="`ITEM`">
<id name="ID" column="`ID`" type="long" unsaved-value="-1">
<generator class="native"/>
</id>
<version name="versionID" column="`VERSIONID`" type="long" unsaved-value="negative" />
<property name="UPC" column="`UPC`" type="string"/>
<property name="shortDescription" column="`SHORTDESCRIPTION`" type="string"/>
<property name="longDescription" column="`LONGDESCRIPTION`" type="string"/>
<property name="cost" column="`COST`" type="double"/>
<property name="instoreCost" column="`INSTORECOST`" type="double"/>
<property name="onlineCost" column="`ONLINECOST`" type="double"/>
<property name="MSRP" column="`MSRP`" type="double"/>
<property name="catalogNumber" column="`CATALOGNUMBER`" type="string"/>
<property name="quantity" column="`QUANTITY`" type="long"/>
<property name="conception" column="`CONCEPTION`" type="timestamp"/>
<property name="releaseDate" column="`RELEASEDATE`" type="timestamp"/>
<property name="used" column="`USED`" type="boolean"/>
<list name="images" table="`ITEMIMAGE`" cascade="all-delete-orphan">
<key column="`ITEMID`"/>
<index column="`INDEX`"/>
<many-to-many class="vitalvinyl.model.item.Image" column="`IMAGEID`"/>
</list>
<list name="reviews" table="`ITEMREVIEW`" cascade="all-delete-orphan">
<key column="`ITEMID`"/>
<index column="`INDEX`"/>
<many-to-many class="vitalvinyl.model.history.Review" column="`REVIEWID`"/>
</list>
<property name="width" column="`WIDTH`" type="long"/>
<property name="height" column="`HEIGHT`" type="long"/>
<property name="depth" column="`DEPTH`" type="long"/>
<property name="weight" column="`WEIGHT`" type="long"/>
<joined-subclass name="vitalvinyl.model.media.Media" table="`MEDIA`">
<key column="`ITEMID`" />
<property name="name" column="`NAME`" type="string" not-null="true" unique="true"/>
<many-to-one name="artist" column="`ARTISTID`" class="vitalvinyl.model.media.Artist"/>
<many-to-one name="type" column="`MEDIATYPEID`" class="vitalvinyl.model.media.MediaType"/>
<many-to-one name="label" column="`LABELID`" class="vitalvinyl.model.media.Label"/>
<many-to-one name="genre" column="`GENREID`" class="vitalvinyl.model.media.Genre"/>
<list name="disks" table="`MEDIADISK`" cascade="all-delete-orphan">
<key column="`MEDIAID`"/>
<index column="`INDEX`"/>
<many-to-many class="vitalvinyl.model.media.Disk" column="`DISKID`"/>
</list>
</joined-subclass>
<joined-subclass name="vitalvinyl.model.gear.Gear" table="`GEAR`">
<key column="`ITEMID`"/>
<property name="name" column="`NAME`" type="string" not-null="true" unique="true"/>
<many-to-one name="distributor" column="`DISTRIBUTOR`" class="vitalvinyl.model.item.Distributor"/>
<many-to-one name="manufacturer" column="`MANUFACTURER`" class="vitalvinyl.model.item.Distributor"/>
<many-to-one name="type" column="`TYPE`" class="vitalvinyl.model.gear.GearType"/>
<property name="warranty" column="`WARRANTY`" type="string"/>
<list name="features" table="GEARFEATURE">
<key column="FEATUREID"/>
<index column="`INDEX`"/>
<element column="FEATURE" type="string"/>
</list>
<property name="color" column="`COLOR`" type="string"/>
<list name="accessories" table="`GEARACCESSORIES`" cascade="all-delete-orphan">
<key column="`GEARID`"/>
<index column="`INDEX`"/>
<many-to-many class="vitalvinyl.model.gear.GearType" column="`ACCESSORYID`"/>
</list>
</joined-subclass>
<joined-subclass name="vitalvinyl.model.promotion.Ticket" table="`TICKET`">
<key column="`ITEMID`"/>
<property name="venue" column="`VENUE`" type="string"/>
<many-to-one name="promoter" column="`PROMOTER`" class="vitalvinyl.model.person.Promoter"/>
<property name="eventStart" column="`EVENTSTART`" type="timestamp"/>
<property name="eventEnd" column="`EVENTEND`" type="timestamp"/>
<property name="sellStart" column="`SELLSTART`" type="timestamp"/>
<property name="sellEnd" column="`SELLEND`" type="timestamp"/>
<property name="minimalAge" column="`MINIMALAGE`" type="long"/>
<property name="website" column="`WEBSITE`" type="string"/>
<property name="email" column="`EMAIL`" type="string"/>
<property name="doorPrice" column="`DOORPRICE`" type="double"/>
<property name="venueAddress" column="`VENUEADDRESS`" type="string"/>
<many-to-one name="headliner" column="`HEADLINER`" class="vitalvinyl.model.media.Artist"/>
<list name="artists" table="`TICKETARTISTS`" cascade="all-delete-orphan">
<key column="`TICKETID`"/>
<index column="`INDEX`"/>
<many-to-many class="vitalvinyl.model.media.Artist" column="`ARTISTID`"/>
</list>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
if (searchContext.get(SearchContext.MEDIA_ARTIST_ID) != null) {
criteria.createCriteria("artist")
.add(Expression.eq("ID", searchContext.get(SearchContext.MEDIA_ARTIST_ID)));
}
Debug level Hibernate log excerpt:
[DEBUG] [05 Jul 2005 16:57:46.765] [SQL] [select this_.`ITEMID` as ID1_1_, this_1_.`VERSIONID` as VERSIONID2_19_1_, this_1_.`UPC` as UPC3_19_1_, this_1_.`SHORTDESCRIPTION` as SHORTDES4_19_1_, this_1_.`LONGDESCRIPTION` as LONGDESC5_19_1_, this_1_.`COST` as COST6_19_1_, this_1_.`INSTORECOST` as INSTOREC7_19_1_, this_1_.`ONLINECOST` as ONLINECOST8_19_1_, this_1_.`MSRP` as MSRP9_19_1_, this_1_.`CATALOGNUMBER` as CATALOG10_19_1_, this_1_.`QUANTITY` as QUANTITY11_19_1_, this_1_.`CONCEPTION` as CONCEPTION12_19_1_, this_1_.`RELEASEDATE` as RELEASE13_19_1_, this_1_.`USED` as USED14_19_1_, this_1_.`WIDTH` as WIDTH15_19_1_, this_1_.`HEIGHT` as HEIGHT16_19_1_, this_1_.`DEPTH` as DEPTH17_19_1_, this_1_.`WEIGHT` as WEIGHT18_19_1_, this_.`NAME` as NAME2_22_1_, this_.`ARTISTID` as ARTISTID3_22_1_, this_.`MEDIATYPEID` as MEDIATYP4_22_1_, this_.`LABELID` as LABELID5_22_1_, this_.`GENREID` as GENREID6_22_1_, artist1_.`ID` as ID1_0_, artist1_.`VERSIONID` as VERSIONID2_0_0_, artist1_.`NAME` as NAME3_0_0_, artist1_.`SHORTDESCRIPTION` as SHORTDES4_0_0_, artist1_.`LONGDESCRIPTION` as LONGDESC5_0_0_ from `MEDIA` this_ inner join `ITEM` this_1_ on this_.`ITEMID`=this_1_.`ID` inner join `ARTIST` artist1_ on this_.`ARTISTID`=artist1_.`ID` where this_.`NAME` like ? and artist1_.`ID`=? order by this_.`NAME` asc]
[DEBUG] [05 Jul 2005 16:57:46.765] [AbstractBatcher] [preparing statement]
[DEBUG] [05 Jul 2005 16:57:46.843] [StringType] [binding '%Britney Does Dallas%' to parameter: 1]
[DEBUG] [05 Jul 2005 16:57:46.843] [LongType] [binding '1' to parameter: 2]
[DEBUG] [05 Jul 2005 16:57:46.859] [AbstractBatcher] [about to open ResultSet (open ResultSets: 0, globally: 0)]
Name and version of the database you are using:
MySQL - latest
Problem
The SQL when run through the SQL window using the supplied paramters, returns a row, but Hibernate is returning 0 results. Is the mapping correct?
I am at a loss why the bound parameters are not rendering the SQL I am looking for.