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 没有被映射。

求各位帮小弟。
...全文
140 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
keerqin 2006-12-16
  • 打赏
  • 举报
回复
是配置文件的问题不过不是hibernate.cfgxml,是application_context.xml力没配。看了老兄的提示,恍然大悟
wuzeng2002 2006-12-14
  • 打赏
  • 举报
回复
是不是配置文件放的位置不对啊? hibernate.cfgxml文件里要包含你上面的那个配置文件 比如加上<mapping resource="VNews.hbm.xml" />这行
1. 简介 2. 起步 2.1 下载并安装Grails 2.2 创建一个Grails应用 2.3 Hello World示例 2.4 使用IDE 2.5 规约配置 2.6 运行Grails应用 2.7 测试Grails应用 2.8 部署Grails应用 2.9 所支持的Java EE容器 2.10 创建工件 2.11 生成Grails应用 3. 配置 3.1 基本配置 3.1.1 内置选项 3.1.2 日志 3.2 环境 3.3 数据源 3.3.1 数据源和环境 3.3.2 JNDI数据源 3.3.3 自动数据库移植 3.4 外部配置 3.5 定义版本 4. 命令行 4.1 创建Gant脚本 4.2 可复用的Grails脚本 4.3 脚本中的事件 4.4 Ant和Maven 5. 对象关系映射(GORM) 5.1 快速指南 5.1.1 基本的CRUD 5.2 在GORM中进行领域建模 5.2.1 GORM中的关联 5.2.1.1 一对一 5.2.1.2 一对多 5.2.1.3 多对多 5.2.2 GORM的组合 5.2.3 GORM的继承 5.2.4 集合、列表和映射 5.3 持久化基础 5.3.1 保存和更新 5.3.2 删除对象 5.3.3 级联更新和删除 5.3.4 立即加载和延迟加载 5.3.4 悲观锁和乐观锁 5.4 GORM查询 5.4.1 动态查找器 5.4.2 条件查询 5.4.3 Hibernate查询语言 5.5 高级GORM特性 5.5.1 事件和自动实现时间戳 5.5.2 自定义ORM映射 5.5.2.1 表名和列名 5.5.2.2 缓存策略 5.5.2.3 继承策略 5.5.2.4 自定义数据库标识符 5.5.2.5 复合主键 5.5.2.6 数据库索引 5.5.2.7 乐观锁和版本定义 5.5.2.8 立即加载和延迟加载 5.6 事务编程 5.7 GORM和约束 6. Web层 6.1 控制器 6.1.1 理解控制器和操作 6.1.2 控制器和作用域 6.1.3 模型和视图 6.1.4 重定向和链 6.1.5 控制器拦截器 6.1.6 数据绑定 6.1.7 XML和JSON响应 6.1.8 上传文件 6.1.9 命令对象 6.2 Groovy Server Pages 6.2.1 GSP基础 6.2.1.1 变量和作用域 6.2.1.2 逻辑和迭代 6.2.1.3 页面指令 6.2.1.4 表达式 6.2.2 GSP标签 6.2.2.1 变量和作用域 6.2.2.2 逻辑和迭代 6.2.2.3 搜索和过滤 6.2.2.4 链接和资源 6.2.2.5 表单和字段 6.2.2.6 标签作为方法调用 6.2.3 视图和模板 6.2.4 使用Sitemesh布局 6.3 标签库 6.3.1 简单标签 6.3.2 逻辑标签 6.3.3 迭代标签 6.3.4 标签命名空间 6.4 URL映射 6.4.1 映射到控制器和操作 6.4.2 嵌入式变量 6.4.3 映射到视图 6.4.4 映射到响应代码 6.4.5 映射到HTTP方法 6.4.6 映射通配符 6.4.7 自动重写链接 6.4.8 应用约束 6.5 Web Flow 6.5.1 开始和结束状态 6.5.2 操作状态和视图状态 6.5.3 流执行事件 6.5.4 流的作用域 6.5.5 数据绑定和验证 6.5.6 子流程和会话 6.6 过滤器 6.6.1 应用过滤器 6.6.2 过滤器的类型 6.6.3 过滤器的功能 6.7 Ajax 6.7.1 用Prototype实现Ajax 6.7.1.1 异步链接 6.7.1.2 更新内容 6.7.1.3 异步表单提交 6.7.1.4 Ajax事件 6.7.2 用Dojo实现Ajax 6.7.3 用GWT实现Ajax 6.7.4 服务端的Ajax 6.8 内容协商 7. 验证 7.1 声明约束 7.2 验证约束 7.3 客户端验证 7.4 验证和国际化 8. 服务层 8.1 声明式事务 8.2 服务的作用域 8.3 依赖注入和服务 8.4 使用Java的服务 9. 测试 9.1 单元测试 9.2 集成测试 9.3 功能测试 10. 国际化 10.1 理解信息绑定 10.2 改变Locales 10.3 读取信息 11. 安全 11.1 预防攻击 11.2 字符串的编码和解码 11.3 身份验证 11.4 关于安全的插件 11.4.1 Acegi 11.4.2 JSecurity 12 插件 12.1 创建和安装插件 12.2 理解插件的结构 12.3 提供基础的工件 12.4 评估规约 12.5 参与构建事件 12.6 参与运行时配置 12.7 运行时添加动态方法 12.8 参与自动重载 12.9 理解插件加载的顺序 13. Web服务 13.1 REST 13.2 SOAP 13.3 RSS和Atom 14. Grails和Spring 14.1 Grails的支柱 14.2 配置其他Bean 14.3 通过Beans DSL运行Spring 14.4 配置属性占位 14.5 配置属性重载 15. Grails和Hibernate 15.1 通过Hibernate注释进行映射 15.2 深入了解 16. 脚手架

81,094

社区成员

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

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