I have two tables, one called Guest and and another called Reservation, in a MySQL database. My MySQL database install does not seem allow me to use ForeignKeys (apparently they are only support by INNODB tables).
The Guest table has columns ( guestId, lastName, firstName, phone ).
The Reservation table has columns ( id, date, time, guestId ).
One guest can have multiple reservations and each reservation refers to only one guest.
I want to be able to do a lookup for any reservations in the name of the above specifies guest and then return Reservation instances with the getGuest() refering to a Guest instance.
So far I have the following query:
Code:
Criteria criteria = session.createCriteria(Reservation.class)
.createAlias ("guest", "guest0")
.add(Expression.eq("lastName",lastName));
but this does not seem to work. I suspect my problem must be in my definition file. The line I have in my Reservation.hbm.xml files is:
Code:
<one-to-one
name="guest"
foreign-key="guestId"
class="com.symphonize.eresbook.domain.Guest"/>
Can anyone suggest what I should be doing?