-->
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: Paging with composite key.
PostPosted: Wed Aug 17, 2005 10:42 am 
Newbie

Joined: Sun Aug 01, 2004 8:23 pm
Posts: 11
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.9

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

This is not a problem report, but a request for design assistance.

I have a table with a composite key. I want to be able to page through it.

I have devised a conceptual example.
In the example, the table a numeric year and a numeric month column as the composite key. Thus, an order by for year, month would produce rows for 2 years that would be in chronological order. January, 1999 would preceed February, 1999 and January, 2000 would be after all of 1999. There does not seem to be a HQL that could be used on the Id property to order by the ID (year, month in a primary key class). Although it is simple to make the key class comparable (implement Comparable). Is there HQL that would allow me to get instances in 5-month chunks ((01,1999), (02,1999), (03,1999), (04,1999), (05,1999)) - then ((06,1999), (07,1999), (08,1999), (09,1999), (10,1999)) - then ((11,1999), (12,1999),(01,2000), (02,2000), (03,2000)) - etc. I have built a pager for single-column keys, but find multi-column keys a chore. I think it would be best done internally in Hibernate.


Thanks in advance

Wayne


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.