Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrieve records from a table  RSS feed

 
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!
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!