Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate adding .value,.count,.offset, and hash to query

 
Annie McCall
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
--------------------------------------------------------------------------------
Hibernate version: hibernate 3.2.0.cr2

Mapping documents:Annotations

Name and version of the database: Oracle 92

Hi,

Before I show you my code....I explain my problem.
It seems like Hib is adding 4 columns to my query.
Below is the actual SQL that is being generated:
select feedlog0_.FEED_ID as col_0_0_,
feedtype1_.FEED_DESC as col_1_0_,
feedlog0_.FEED_ID as FEED1_3_,
feedlog0_.CRTD_DT as CRTD2_3_,
feedlog0_.FEED_TYPE as FEED3_3_,
feedlog0_.RESULT_STATUS as RESULT4_3_,
feedlog0_.value as value3_,
feedlog0_.offset as offset3_,
feedlog0_.count as count3_,
feedlog0_.hash as hash3_
from FEED_LOG_TB feedlog0_, FEED_TYPE_TB feedtype1_
where feedlog0_.FEED_TYPE=feedtype1_.FEED_CODE


(don't understand how hib is getting .value, .count, .hash, and .offset; I don't have those columns in my table or bean)

ok...
now my code:
my bean:
package com.annie.hcp.businessbeans;

import java.util.Date;
import java.text.NumberFormat;
import java.util.Locale;
import java.io.Serializable;
import java.math.BigInteger;


import javax.persistence.*;
@Entity
@Table(name="FEED_LOG_TB")
@NamedQuery(
name="FeedLog.getFeedsSummary",
query="SELECT fl, ft.feedDesc " +
"FROM FeedLog fl, FeedType ft " +
"WHERE fl.feedTypeCode = ft.feedCode")

public class FeedLog implements Serializable {
private static final long serialVersionUID = 7526472295622776147L;

@Id
@Column(name="FEED_ID")
private BigInteger feedId;
@Column(name="CRTD_DT")
private Date crtdDt;
@Column(name="FEED_TYPE")
private String feedTypeCode;
@Column(name="RESULT_STATUS")
private BigInteger resultStatus;
@Transient
private String feedName;
@Transient
private double dblAmount;
@Transient
private int statusName;
@Transient
private int noOfRecs;

@Embedded
private String feedDesc;
public String getFeedDesc() {
return feedDesc;
}

public void setFeedDesc(String feedDesc) {
this.feedDesc = feedDesc;
}

public Date getCrtdDt(){

return this.crtdDt;
}

public void setCrtdDt(Date param){

this.crtdDt = param;
}

/* Feed Type */

public String getFeedTypeCode(){

return this.feedTypeCode;
}

public void setFeedTypeCode(String param){

this.feedTypeCode = param;
}




/* Double Amount */


public String getDblAmount(){

NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);

String s = n.format(dblAmount);
return s;

}


public void setDblAmount(double param){

this.dblAmount = param;
}


public String getFeedName() {
return feedName;
}

public void setFeedName(String feedName) {
this.feedName = feedName;
}

public int getStatusName() {
return statusName;
}

public void setStatusName(int statusName) {
this.statusName = statusName;
}

public int getNoOfRecs() {
return noOfRecs;
}



public void setNoOfRecs(int param){

this.noOfRecs = param;
}

public BigInteger getFeedId() {
return feedId;
}

public void setFeedId(BigInteger feedId) {
this.feedId = feedId;
}
public BigInteger getResultStatus() {
return resultStatus;
}

public void setResultStatus(BigInteger resultStatus) {
this.resultStatus = resultStatus;
}
/*
public void setFeedType(FeedType feedType1) {
this.feedType1 = feedType1;
}

public FeedType getFeedType1() {
return feedType1;
}

public void setFeedType1(FeedType feedType1) {
this.feedType1 = feedType1;
}


public void setFeedType(FeedType feedType) {
this.feedType = feedType;
}


public String getFeedCode() {
return feedCode;
}

public void setFeedCode(String feedCode) {
this.feedCode = feedCode;
}


public FeedType getFeedtype() {
return feedtype;
}

public void setFeedtype(FeedType feedtype) {
this.feedtype = feedtype;
}


... Now the code from another class where I call the named query:


BaseHibernateDao dao = DaoFactory.getExpenseDao();
/* get days from web.config */
FacesContext facesContext =
FacesContext.getCurrentInstance();
ServletContext servletContext = (ServletContext)
facesContext.getExternalContext().getContext();
this.setFeedDays(BigInteger.valueOf(Long.parseLong
(servletContext.getInitParameter("feedDays"))));
Object[] params = new Object[1];
params[0] =(BigInteger) this.feedDays;
this.feedLogList = (ArrayList)dao.findByNamedQuery ("FeedLog.getFeedsSummary

Tables are FEED_LOG_TB and FEED_TYPE_TB

and here is the error message I receive....
detailMessage= "ORA-00904: "FEEDLOG0_"."HASH": invalid identifier\n"



I have to admit I am new to hibernate and Spring.
Why is hibernate adding those additional 4 columns (.count, .offset, .hash, .value) ??? Query works fine without those columns.


Thanks in advance
 
nachospiu el pollo
Greenhorn
Posts: 1
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic