-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: composite class key-property restriction to createCriteria
PostPosted: Thu Feb 25, 2010 8:24 pm 
Newbie

Joined: Thu Feb 25, 2010 7:55 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.