Hibernate有关问题.大家帮帮小弟我
Hibernate问题...大家帮帮我啊
我现在得到threads.getMForums()的值是与外键相关的全部记录...但是我只想得到前10条..我要怎么做啊...(不用Query)
<set name="MForums" inverse="true" order-by="adddate DESC"> <key> <column name="threadid" length="2" not-null="true" /> </key> <one-to-many class="com.dataSource.MForum"/> </set>
ThreadMoudle tm = new ThreadMoudle (); Session session = HibernateSessionFactory.getSession(); Transaction tran = session.beginTransaction(); MThreads threads = (MThreads)session.get(MThreads.class, id); tm.threads = threads; for (MForum mf : threads.getMForums()) { tm.forum.add(mf); } tran.commit(); HibernateSessionFactory.closeSession();
我现在得到threads.getMForums()的值是与外键相关的全部记录...但是我只想得到前10条..我要怎么做啊...(不用Query)