hibernate 操作视图

keerqin 2006-12-13 08:52:24
package com.pure.bean;



/**
* VNews generated by MyEclipse - Hibernate Tools
*/

public class VNews implements java.io.Serializable {


// Fields

private VNewsId id;


// Constructors

/** default constructor */
public VNews() {
}


/** full constructor */
public VNews(VNewsId id) {
this.id = id;
}


// Property accessors

public VNewsId getId() {
return this.id;
}

public void setId(VNewsId id) {
this.id = id;
}

}

package com.pure.bean;



/**
* VNewsId generated by MyEclipse - Hibernate Tools
*/

public class VNewsId implements java.io.Serializable {


// Fields

private long id;
private String newstitle;
private String newsauthor;


// Constructors

/** default constructor */
public VNewsId() {
}

/** minimal constructor */
public VNewsId(long id) {
this.id = id;
}



// Property accessors

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public String getNewstitle() {
return this.newstitle;
}

public void setNewstitle(String newstitle) {
this.newstitle = newstitle;
}

public String getNewsauthor() {
return this.newsauthor;
}

public void setNewsauthor(String newsauthor) {
this.newsauthor = newsauthor;
}




public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof VNewsId) ) return false;
VNewsId castOther = ( VNewsId ) other;

return (this.getId()==castOther.getId())
&& ( (this.getNewstitle()==castOther.getNewstitle()) || ( this.getNewstitle()!=null && castOther.getNewstitle()!=null && this.getNewstitle().equals(castOther.getNewstitle()) ) )
&& ( (this.getNewsauthor()==castOther.getNewsauthor()) || ( this.getNewsauthor()!=null && castOther.getNewsauthor()!=null && this.getNewsauthor().equals(castOther.getNewsauthor()) ) );
}

public int hashCode() {
int result = 17;

result = 37 * result + (int) this.getId();
result = 37 * result + ( getNewstitle() == null ? 0 : this.getNewstitle().hashCode() );
result = 37 * result + ( getNewsauthor() == null ? 0 : this.getNewsauthor().hashCode() );
return result;
}





}

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.pure.bean.VNews" table="V_NEWS" schema="CMDBUSER">
<composite-id name="id" class="com.pure.bean.VNewsId">
<key-property name="id" type="int">
<column name="ID" precision="11" />
</key-property>
<key-property name="newstitle" type="string">
<column name="NEWSTITLE" length="50" />
</key-property>
<key-property name="newsauthor" type="string">
<column name="NEWSAUTHOR" length="30" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>



当执行session.createquery("from VNews ")时总报VNews 没有被映射。

求各位帮小弟。
...全文
141 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
keerqin 2006-12-16
  • 打赏
  • 举报
回复
是配置文件的问题不过不是hibernate.cfgxml,是application_context.xml力没配。看了老兄的提示,恍然大悟
wuzeng2002 2006-12-14
  • 打赏
  • 举报
回复
是不是配置文件放的位置不对啊? hibernate.cfgxml文件里要包含你上面的那个配置文件 比如加上<mapping resource="VNews.hbm.xml" />这行

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧