Hibernate 注解视图能和注解表一样的注解吗??

lifa 发布于 2013/01/21 17:18
阅读 7K+
收藏 1

 环境是:Struts2+Spring+Hibernate

数据库用的是mysql,服务器jboss,

我在数据库中新建了一个视图,在java类中新建了一个实体类与其对应,在jboss启动时报此实体类无法映射

@Entity
@Table(name = "kan2")
这是我在实体类中的注解

加载中
0
JavaOlder
JavaOlder
你有配置 persistence.xml这个文件么?
0
lifa
lifa

引用来自“JavaNewPer”的答案

你有配置 persistence.xml这个文件么?
没有啊
JavaOlder
JavaOlder
那不行啊。要实现JPA。没有你怎么映射过去~
0
天马行空&
天马行空&

注释是可以的.至少我们oralce数据库是没有问题,mysql没有试过,不过应该错不多.jboss上没有运行过,tomcat上运行是没有问题.

注释好像没有听说过要配置persistence.xml文件.

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@org.hibernate.annotations.Entity
@Table(name = "ECP_V_PROJECT_COUNT")
public class ProjectCountView implements GpcBaseObject{
	
	/** serialVersionUID */
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "projId", length = 36)
	private String objId; //主键
	
	@Column(name = "subProjectC")
	private BigDecimal subProjectC = new BigDecimal("0"); //分包数目
	
	@Column(name = "signUpC")
	private BigDecimal signUpC = new BigDecimal("0");; //参与供应商数目

	@Column(name = "signUpValidC")
	private BigDecimal signUpValidC = new BigDecimal("0");; //有效参与供应商数目
	
	@Column(name = "bidC")
	private BigDecimal bidC = new BigDecimal("0");; //参与投标供应商数目
	
	@Column(name = "bidValidC")
	private BigDecimal bidValidC = new BigDecimal("0");; //有效参与投标供应商数目
	
	@Column(name = "winnerC")
	private BigDecimal winnerC = new BigDecimal("0");; //中标供应商数目

	public String getObjId() {
		return objId;
	}

	public void setObjId(String objId) {
		this.objId = objId;
	}

	public BigDecimal getSubProjectC() {
		return this.subProjectC;
	}

	public void setSubProjectC(BigDecimal subProjectC) {
		this.subProjectC = subProjectC;
	}

	public BigDecimal getSignUpC() {
		return this.signUpC;
	}

	public void setSignUpC(BigDecimal signUpC) {
		this.signUpC = signUpC;
	}

	public BigDecimal getSignUpValidC() {
		return this.signUpValidC;
	}

	public void setSignUpValidC(BigDecimal signUpValidC) {
		this.signUpValidC = signUpValidC;
	}

	public BigDecimal getBidC() {
		return this.bidC;
	}

	public void setBidC(BigDecimal bidC) {
		this.bidC = bidC;
	}

	public BigDecimal getBidValidC() {
		return this.bidValidC;
	}

	public void setBidValidC(BigDecimal bidValidC) {
		this.bidValidC = bidValidC;
	}

	public BigDecimal getWinnerC() {
		return this.winnerC;
	}

	public void setWinnerC(BigDecimal winnerC) {
		this.winnerC = winnerC;
	}

	public Date getCreateTime() {
		// TODO Auto-generated method stub
		return null;
	}

	public void setCreateTime(Date arg0) {
		// TODO Auto-generated method stub
		
	}
}
CREATE OR REPLACE VIEW ECP_V_PROJECT_COUNT AS
SELECT proj.tenderid as projId,(
       SELECT COUNT(pack.tenderid) FROM ECP_Tender_Project pack WHERE pack.parent_id = proj.tenderid
) subProjectC,(
       SELECT COUNT(apply.applyid) FROM ECP_TENDER_APPLY_REC apply WHERE apply.tenderid = proj.tenderid
) signUpC ,(
       SELECT COUNT(apply1.Applyid) FROM ECP_TENDER_APPLY_REC apply1 WHERE apply1.tenderid = proj.tenderid AND apply1.Auditstatus='01'
)signUpValidC,(
       SELECT COUNT(bid.bid_id) FROM ECP_BID bid WHERE bid.proj_id = proj.tenderid
) bidC,(
       SELECT COUNT(bid1.bid_id) FROM ECP_BID bid1 WHERE bid1.proj_id = proj.tenderid
)bidValidC ,(
       SELECT COUNT(winner.buy_w_id) FROM ECP_BUY_WINNER winner
       LEFT JOIN ECP_BUYRESULT buyResult on buyResult.BUYR_ID = winner.BUYR_ID
       WHERE winner.RESULT_TYPE = '01' AND buyResult.PROJ_ID = proj.tenderid
)winnerC
FROM ECP_Tender_Project proj WHERE proj.parent_id is null;

返回顶部
顶部