• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving the same row

 
Paul Michael Serrano
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I would like to ask something regarding Hibernate.

When I invoke this in MS SQL
select * from survey_log where reporterid = 15046
-->this is the result
repId date1 date2
150463960961000
150463960961105
150463960961098
150463960961014
150463960961042
150463960961021
150463960961070
150463960961035
150463960961063
150463960961028

My SurveyLog.hbm.xml
<hibernate-mapping>
<class name="com.nielsen.beans.dj.SurveyLog" table="survey_log" lazy="true">
<id name="reporterId" column="reporterid">
</id>
<property name="submissionDate" column="submission_date"/>
<property name="issueDate" column="issue_date"/>
<property name="suspFlag" formula="(select count(*) from survey_staging c where c.reporterid = reporterid and c.date = issue_date)" />
<property name="dateValueIss" formula="(dateadd(d, issue_date, '12/31/1840'))"/>
<property name="dateValueSub" formula="(dateadd(d, submission_date, '12/31/1840'))"/>
</class>
</hibernate-mapping>

My partial hibernate code
results = sess.createCriteria(SurveyLog.class).add(Restrictions.eq("reporterId", new Long(reporterId))).setFirstResult(firstRecord).setMaxResults(groupPerPage).list();

My partial Bean
<with getter/setter>
private long reporterId;
private Date submissionDate;
private Date issueDate;
private long countSuspFlag;
private List logList = new ArrayList();
private String stringSubmDate;
private String stringIssueDate;
private String suspFlag;


My problem is, when I execute it in hibernate, I also receive 10 rows, but I always get the value of the first row.
repId date1 date2
150463960961000
150463960961000
150463960961000
150463960961000
150463960961000
150463960961000
150463960961000
150463960961000
150463960961000
150463960961000


The table survey_log has 3 columns
reporterid(int not null), submission_date(int) and issue_date(int)
non of the 3 is a primary key or a foreign key.


Paul
 
Paul Michael Serrano
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I gave the wrong attributes for the bean
<with getters and setters>
private long reporterId;
private long submissionDate;
private long issueDate;
private long suspFlag;
private Date dateValueIss;
private Date dateValueSub;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic