• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrieve records from a table

 
Håkan Axheim
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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:

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

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!
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!