• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Mike London

How to retrieve records from a table

Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a question regarding how to retrieve records from a table that consists with one composite key.
In my hbm.cfg I have specified my composite key with this section:

<key-property name="year"/>
<key-property name="month"/>

I have a POJO class with all the "columns" that exists in my table.
How should I write this POJO class regarding to my composite key.

In the same package I hava a DAO class that retreives all records from the database.
How should I write a DAO method that retrieves all records from the table regarding to my composite key.
SQL query: select year,month,sallary from sallary where year>=2002

If I don't specify the composite key in my hbm.cfg hibernate retrieves too many records in my DAO object.
One record will be listed several times in the query result. Don't know why!
    Bookmark Topic Watch Topic
  • New Topic