Querying a database view in hibernate
<p>I am getting wrong result list when I am trying to retrieve values from a view in hibernate</p>

<p>My bean class is</p>

<pre><code>@Entity
@Table(name = "ACS_Rate_Transmission_Status")
@NamedQueries({
    @NamedQuery(name = NamedQueryStatements.RateStatusByTransId_Name, query = "from AcsRateTransmissionStatus where TransmissionID =:transmissionID"),

})
public class AcsRateTransmissionStatus implements java.io.Serializable {

public AcsRateTransmissionStatus() {
}
private Long transmissionId;
private Integer duncanCustomerId;
private Integer duncanAreaId;
private Integer duncanMeterId;
private Integer duncanBayId;
private Integer spaceNum;
private Integer rateInCent;
private Date receivedTs;
private Date implementationDate;
private Date jobScheudled;
private Date rateActivated;
private Date acknowledged;
private Integer srNo;
private String cssClass = "odd";

@Id
@Column(name = "TransmissionID", nullable = false)
public Long getTransmissionId() {
    return this.transmissionId;
}

public void setTransmissionId(Long transmissionId) {
    this.transmissionId = transmissionId;
}

@Column(name = "DuncanCustomerId", nullable = false)
public Integer getDuncanCustomerId() {
    return this.duncanCustomerId;
}

public void setDuncanCustomerId(Integer duncanCustomerId) {
    this.duncanCustomerId = duncanCustomerId;
}

@Column(name = "DuncanAreaId", nullable = false)
public Integer getDuncanAreaId() {
    return this.duncanAreaId;
}

public void setDuncanAreaId(Integer duncanAreaId) {
    this.duncanAreaId = duncanAreaId;
}

@Column(name = "DuncanMeterId")
public Integer getDuncanMeterId() {
    return this.duncanMeterId;
}

public void setDuncanMeterId(Integer duncanMeterId) {
    this.duncanMeterId = duncanMeterId;
}

@Column(name = "DuncanBayId")
public Integer getDuncanBayId() {
    return this.duncanBayId;
}

public void setDuncanBayId(Integer duncanBayId) {
    this.duncanBayId = duncanBayId;
}

@Column(name = "SpaceNum")
public Integer getSpaceNum() {
    return this.spaceNum;
}

public void setSpaceNum(Integer spaceNum) {
    this.spaceNum = spaceNum;
}

@Column(name = "RateInCent")
public Integer getRateInCent() {
    return this.rateInCent;
}

public void setRateInCent(Integer rateInCent) {
    this.rateInCent = rateInCent;
}

@Column(name = "ReceivedTS")
@Temporal(TemporalType.TIMESTAMP)
public Date getReceivedTs() {
    return this.receivedTs;
}

public void setReceivedTs(Date receivedTs) {
    this.receivedTs = receivedTs;
}

@Column(name = "ImplementationDate")
@Temporal(TemporalType.TIMESTAMP)
public Date getImplementationDate() {
    return this.implementationDate;
}

public void setImplementationDate(Date implementationDate) {
    this.implementationDate = implementationDate;
}

@Column(name = "JobScheudled")
@Temporal(TemporalType.TIMESTAMP)
public Date getJobScheudled() {
    return this.jobScheudled;
}

public void setJobScheudled(Date jobScheudled) {
    this.jobScheudled = jobScheudled;
}

@Column(name = "RateActivated")
@Temporal(TemporalType.TIMESTAMP)
public Date getRateActivated() {
    return this.rateActivated;
}

public void setRateActivated(Date rateActivated) {
    this.rateActivated = rateActivated;
}

@Column(name = "Acknowledged")
@Temporal(TemporalType.TIMESTAMP)
public Date getAcknowledged() {
    return this.acknowledged;
}

public void setAcknowledged(Date acknowledged) {
    this.acknowledged = acknowledged;
}

/**
 * @return the srNo
 */
@Transient
public Integer getSrNo() {
    return srNo;
}

/**
 * @param srNo the srNo to set
 */
public void setSrNo(Integer srNo) {
    this.srNo = srNo;
}

/**
 * @return the cssClass
 */
</code></pre>

<p>@Transient
    public String getCssClass() {
        return cssClass;
    }</p>

<pre><code>/**
 * @param cssClass the cssClass to set
 */
public void setCssClass(String cssClass) {
    this.cssClass = cssClass;
}
</code></pre>

<p>}</p>

<p>And from my service class for value transId=5512</p>

<pre><code> public List&lt;AcsRateTransmissionStatus&gt; getModel(Long transId) throws ParseException, Exception {


    Map&lt;String, Object&gt; m = new HashMap&lt;String, Object&gt;();
    m.put("transmissionID", transId);
</code></pre>

<p>ArrayList list = dao.namedQuery(NamedQueryStatements.RateStatusByTransId_Name, m);
for (AcsRateTransmissionStatus a: list) {</p>

<pre><code>        a.setSrNo(++srNo);
        debug("space number==" + a.getSpaceNum());
        if (srNo % 2 == 0) {
            a.setCssClass("even");
        }

    }

    return list;
}
</code></pre>

<p>I am getting resultt like:</p>

<pre><code>No  Transmission ID     Customer ID     Area ID     Meter ID    Bay Number  Space Number    Rate In Cent    Received TS     Implementation Date     Job Scheduled TS    Activated TS    Acknowledged TS
</code></pre>

<p>3    5512   9991    1   10001   1   101     350     2012-11-07 23:24:33.437     2012-10-12 20:45:00.0<br>
<strong>3     5512    9991    1   10001   1   101     350     2012-11-07 23:24:33.437     2012-10-12 20:45:00.0</strong><br>
3   5512    9991    1   10001   1   101     350     2012-11-07 23:24:33.437     2012-10-12 20:45:00.0 </p>

<p>Instead of </p>

<pre><code>TransmissionID       DuncanCustomerId DuncanAreaId DuncanMeterId DuncanBayId SpaceNum    RateInCent  ReceivedTS              ImplementationDate      JobScheudled            RateActivated           Acknowledged
</code></pre>

<hr>

<p>5512 9991 1 10001 1 101 350 2012-11-07 23:24:33.437 2012-10-12 20:45:00.000 NULL NULL NULL<br>
<strong>5512 9991 1 10002 1 102 350 2012-11-07 23:24:33.437 2012-10-12 20:45:00.000 NULL</strong> NULL NULL<br>
5512 9991 1 10001 1 101 350 2012-11-07 23:24:33.437 2012-10-12 20:45:00.000 NULL NULL NULL  </p>

<p>(3 row(s) affected)</p>
