Hi, How could I add Restrictions to the createCriteria using composite-id key ? The program works fine with session.createCriteria(Calendar.class).list(); but i do not know how to restrict it by a key-property name="courseId". The composite-id class is CalendarId. Here are my codes:
CalendarId idCalendar=new CalendarId(courseId);
list= session.createCriteria(Calendar.class).list();
defined the calendar table with two classes Calendar.class and CalendarId.class(for Composite id)
and the calendar.hbm.xml : <hibernate-mapping> <class name="entity.Calendar" table="calendar" catalog="cwsei_hibernate"> <composite-id name="id" class="entity.CalendarId"> <key-property name="id" type="int"> <column name="Id" /> </key-property> <key-property name="courseId" type="int"> <column name="courseId" /> </key-property> <key-property name="year" type="string"> <column name="year" length="4" /> </key-property> </composite-id> <property name="title" type="string"> <column name="title" /> </property> ..........
<property name="title" type="string"> <column name="title" /> </property> </class> </hibernate-mapping> Thanks, MK
|