`
tanlingcau
  • 浏览: 138073 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Hibernate 查询视图

阅读更多
V4cDiseasesprevention
package com.SAFAS.mobilecatch.server.hibernate.model;

/**
 * V4cDiseasesprevention entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class V4cDiseasesprevention implements java.io.Serializable {

	// Fields

	private V4cDiseasespreventionId id;

	// Constructors

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

	/** full constructor */
	public V4cDiseasesprevention(V4cDiseasespreventionId id) {
		this.id = id;
	}

	// Property accessors

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

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

}


V4cDiseasespreventionId
package com.SAFAS.mobilecatch.server.hibernate.model;

/**
 * V4cDiseasespreventionId entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class V4cDiseasespreventionId implements java.io.Serializable {

	// Fields

	private Integer produceClassify4id;
	private String produceClassify4name;
	private Short qualityStandardId;
	private Short environmentStandardId;
	private Short producingRuleId;
	private Short produceSampleStandardId;
	private String producingRuleCode;
	private String producingRuleName;
	private String remark;
	private String pesticideName;
	private String preventionMethod;

	// Constructors

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

	/** minimal constructor */
	public V4cDiseasespreventionId(Integer produceClassify4id) {
		this.produceClassify4id = produceClassify4id;
	}

	/** full constructor */
	public V4cDiseasespreventionId(Integer produceClassify4id,
			String produceClassify4name, Short qualityStandardId,
			Short environmentStandardId, Short producingRuleId,
			Short produceSampleStandardId, String producingRuleCode,
			String producingRuleName, String remark, String pesticideName,
			String preventionMethod) {
		this.produceClassify4id = produceClassify4id;
		this.produceClassify4name = produceClassify4name;
		this.qualityStandardId = qualityStandardId;
		this.environmentStandardId = environmentStandardId;
		this.producingRuleId = producingRuleId;
		this.produceSampleStandardId = produceSampleStandardId;
		this.producingRuleCode = producingRuleCode;
		this.producingRuleName = producingRuleName;
		this.remark = remark;
		this.pesticideName = pesticideName;
		this.preventionMethod = preventionMethod;
	}

	// Property accessors

	public Integer getProduceClassify4id() {
		return this.produceClassify4id;
	}

	public void setProduceClassify4id(Integer produceClassify4id) {
		this.produceClassify4id = produceClassify4id;
	}

	public String getProduceClassify4name() {
		return this.produceClassify4name;
	}

	public void setProduceClassify4name(String produceClassify4name) {
		this.produceClassify4name = produceClassify4name;
	}

	public Short getQualityStandardId() {
		return this.qualityStandardId;
	}

	public void setQualityStandardId(Short qualityStandardId) {
		this.qualityStandardId = qualityStandardId;
	}

	public Short getEnvironmentStandardId() {
		return this.environmentStandardId;
	}

	public void setEnvironmentStandardId(Short environmentStandardId) {
		this.environmentStandardId = environmentStandardId;
	}

	public Short getProducingRuleId() {
		return this.producingRuleId;
	}

	public void setProducingRuleId(Short producingRuleId) {
		this.producingRuleId = producingRuleId;
	}

	public Short getProduceSampleStandardId() {
		return this.produceSampleStandardId;
	}

	public void setProduceSampleStandardId(Short produceSampleStandardId) {
		this.produceSampleStandardId = produceSampleStandardId;
	}

	public String getProducingRuleCode() {
		return this.producingRuleCode;
	}

	public void setProducingRuleCode(String producingRuleCode) {
		this.producingRuleCode = producingRuleCode;
	}

	public String getProducingRuleName() {
		return this.producingRuleName;
	}

	public void setProducingRuleName(String producingRuleName) {
		this.producingRuleName = producingRuleName;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getPesticideName() {
		return this.pesticideName;
	}

	public void setPesticideName(String pesticideName) {
		this.pesticideName = pesticideName;
	}

	public String getPreventionMethod() {
		return this.preventionMethod;
	}

	public void setPreventionMethod(String preventionMethod) {
		this.preventionMethod = preventionMethod;
	}

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

		return ((this.getProduceClassify4id() == castOther
				.getProduceClassify4id()) || (this.getProduceClassify4id() != null
				&& castOther.getProduceClassify4id() != null && this
				.getProduceClassify4id().equals(
						castOther.getProduceClassify4id())))
				&& ((this.getProduceClassify4name() == castOther
						.getProduceClassify4name()) || (this
						.getProduceClassify4name() != null
						&& castOther.getProduceClassify4name() != null && this
						.getProduceClassify4name().equals(
								castOther.getProduceClassify4name())))
				&& ((this.getQualityStandardId() == castOther
						.getQualityStandardId()) || (this
						.getQualityStandardId() != null
						&& castOther.getQualityStandardId() != null && this
						.getQualityStandardId().equals(
								castOther.getQualityStandardId())))
				&& ((this.getEnvironmentStandardId() == castOther
						.getEnvironmentStandardId()) || (this
						.getEnvironmentStandardId() != null
						&& castOther.getEnvironmentStandardId() != null && this
						.getEnvironmentStandardId().equals(
								castOther.getEnvironmentStandardId())))
				&& ((this.getProducingRuleId() == castOther
						.getProducingRuleId()) || (this.getProducingRuleId() != null
						&& castOther.getProducingRuleId() != null && this
						.getProducingRuleId().equals(
								castOther.getProducingRuleId())))
				&& ((this.getProduceSampleStandardId() == castOther
						.getProduceSampleStandardId()) || (this
						.getProduceSampleStandardId() != null
						&& castOther.getProduceSampleStandardId() != null && this
						.getProduceSampleStandardId().equals(
								castOther.getProduceSampleStandardId())))
				&& ((this.getProducingRuleCode() == castOther
						.getProducingRuleCode()) || (this
						.getProducingRuleCode() != null
						&& castOther.getProducingRuleCode() != null && this
						.getProducingRuleCode().equals(
								castOther.getProducingRuleCode())))
				&& ((this.getProducingRuleName() == castOther
						.getProducingRuleName()) || (this
						.getProducingRuleName() != null
						&& castOther.getProducingRuleName() != null && this
						.getProducingRuleName().equals(
								castOther.getProducingRuleName())))
				&& ((this.getRemark() == castOther.getRemark()) || (this
						.getRemark() != null
						&& castOther.getRemark() != null && this.getRemark()
						.equals(castOther.getRemark())))
				&& ((this.getPesticideName() == castOther.getPesticideName()) || (this
						.getPesticideName() != null
						&& castOther.getPesticideName() != null && this
						.getPesticideName()
						.equals(castOther.getPesticideName())))
				&& ((this.getPreventionMethod() == castOther
						.getPreventionMethod()) || (this.getPreventionMethod() != null
						&& castOther.getPreventionMethod() != null && this
						.getPreventionMethod().equals(
								castOther.getPreventionMethod())));
	}

	public int hashCode() {
		int result = 17;

		result = 37
				* result
				+ (getProduceClassify4id() == null ? 0 : this
						.getProduceClassify4id().hashCode());
		result = 37
				* result
				+ (getProduceClassify4name() == null ? 0 : this
						.getProduceClassify4name().hashCode());
		result = 37
				* result
				+ (getQualityStandardId() == null ? 0 : this
						.getQualityStandardId().hashCode());
		result = 37
				* result
				+ (getEnvironmentStandardId() == null ? 0 : this
						.getEnvironmentStandardId().hashCode());
		result = 37
				* result
				+ (getProducingRuleId() == null ? 0 : this.getProducingRuleId()
						.hashCode());
		result = 37
				* result
				+ (getProduceSampleStandardId() == null ? 0 : this
						.getProduceSampleStandardId().hashCode());
		result = 37
				* result
				+ (getProducingRuleCode() == null ? 0 : this
						.getProducingRuleCode().hashCode());
		result = 37
				* result
				+ (getProducingRuleName() == null ? 0 : this
						.getProducingRuleName().hashCode());
		result = 37 * result
				+ (getRemark() == null ? 0 : this.getRemark().hashCode());
		result = 37
				* result
				+ (getPesticideName() == null ? 0 : this.getPesticideName()
						.hashCode());
		result = 37
				* result
				+ (getPreventionMethod() == null ? 0 : this
						.getPreventionMethod().hashCode());
		return result;
	}

}



V4cDiseasesprevention.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!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 Persistence Tools
-->
<hibernate-mapping>
    <class name="com.pickedpoint.SAFAS.mobilecatch.server.hibernate.model.V4cDiseasesprevention" table="v_4c_diseasesprevention" catalog="safas">
        <composite-id name="id" class="com.pickedpoint.SAFAS.mobilecatch.server.hibernate.model.V4cDiseasespreventionId">
            <key-property name="produceClassify4id" type="java.lang.Integer">
                <column name="produceClassify_4ID" />
            </key-property>
            <key-property name="produceClassify4name" type="java.lang.String">
                <column name="produceClassify_4Name" length="20" />
            </key-property>
            <key-property name="qualityStandardId" type="java.lang.Short">
                <column name="qualityStandardID" />
            </key-property>
            <key-property name="environmentStandardId" type="java.lang.Short">
                <column name="environmentStandardID" />
            </key-property>
            <key-property name="producingRuleId" type="java.lang.Short">
                <column name="producingRuleID" />
            </key-property>
            <key-property name="produceSampleStandardId" type="java.lang.Short">
                <column name="produceSampleStandardID" />
            </key-property>
            <key-property name="producingRuleCode" type="java.lang.String">
                <column name="producingRuleCode" />
            </key-property>
            <key-property name="producingRuleName" type="java.lang.String">
                <column name="producingRuleName" length="50" />
            </key-property>
            <key-property name="remark" type="java.lang.String">
                <column name="remark" />
            </key-property>
            <key-property name="pesticideName" type="java.lang.String">
                <column name="pesticideName" length="50" />
            </key-property>
            <key-property name="preventionMethod" type="java.lang.String">
                <column name="preventionMethod" />
            </key-property>
        </composite-id>
    </class>
</hibernate-mapping>



package com..SAFAS.mobilecatch.server.hibernate.website.DAO;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com..SAFAS.mobilecatch.server.hibernate.SessionFactory.HibernateSessionFactory;

public class V4cDiseasespreventionIdOperate {

	public V4cDiseasespreventionIdOperate() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * 查询全部
	 * @return
	 * 
	 * @author 
	 */
	public List Query(){
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery("from V4cDiseasesprevention");
		List list = query.list();
		if(session.isOpen()){
			session.close();
		}
		return list;
	}
	
	/**
	 * 根据产品名称查询
	 * @param produceClassify4name
	 * @return
	 * 
	 * @author
	 */
	public List QueryByName(String produceClassify4name){
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery("from V4cDiseasesprevention where produceClassify4name = '" + produceClassify4name + "'");
		List list = query.list();
		if(session.isOpen()){
			session.close();
		}
		return list;
	}
      public List Test(){
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery("from V4cSensequalitystandard v where v.id.senseStandard like '%的%'");
		List list = query.list();
		if(session.isOpen()){
			session.close();
		}
		return list;
	}
	
}

分享到:
评论
1 楼 java-xb 2009-08-12  
我试过了,list 里面有,但是输出不了东西。

相关推荐

    Hibernate的视图功能

    Hibernate的视图功能 网上找的 , 自己实验过,能用

    hibernate 视图

    当查询一个视图时,Hibernate会生成相应的SQL语句去执行视图查询。通过阅读源码,我们可以了解到Hibernate如何处理不同类型的查询以及对视图的支持。 **总结** 总之,Hibernate视图提供了对数据库视图的封装,使得...

    struts+hibernate查询所有记录

    ### Struts+Hibernate查询所有记录 #### 一、概述 在Java Web开发中,Struts与Hibernate是非常流行的框架组合,用于构建复杂的企业级应用。本文将详细介绍如何利用Struts和Hibernate来实现对Oracle数据库中所有...

    J2EE企业级项目开发-1期 06 hibernate映射视图的使用经验.doc

    总结起来,在J2EE项目开发中,使用Hibernate映射视图是一种解决复杂查询和跨表统计的有效策略。当原生SQL不适用时,创建视图并进行相应的ORM配置可以保持代码的整洁性和可维护性。需要注意的是,视图的映射可能会...

    hibernate实现动态SQL查询

    本篇文章主要探讨如何利用Hibernate实现动态SQL查询,结合XML配置和FREEMARKER模板引擎来生成执行的SQL语句。 一、Hibernate简介 Hibernate作为一款强大的持久层框架,它简化了Java应用程序与数据库之间的交互。...

    hibernate子查询

    在使用Hibernate进行数据查询时,有时会遇到需要使用子查询的情况。然而,正如你所描述的,Hibernate的HQL(Hibernate Query Language)并不直接支持在`FROM`子句后跟一个子查询,这与标准的SQL语法有所差异。在HQL...

    Hibernate 多表连接分页查询示范项目

    7. **处理结果**:遍历查询结果,将数据绑定到视图或者进一步处理。 总结,"Hibernate 多表连接分页查询示范项目"是一个实用的示例,它展示了如何在实际应用中利用 Hibernate Criteria API 实现复杂查询和分页,...

    Struts和Hibernate分页及查询

    本实践项目结合了这两个框架,实现了基于Struts的前端展示和基于Hibernate的数据访问层,提供了分页和条件查询功能,这对于大型Web应用来说是非常基础且重要的。 **Struts框架** 是一个用于构建企业级Web应用程序的...

    struts2+spring2+hibernate3注册查询搜索分页实例

    在查询和搜索功能中,Hibernate3通过HQL(Hibernate查询语言)或 Criteria API来执行SQL查询,简化了数据库操作。在分页功能中,Hibernate3的Criteria API可以配合Pageable接口实现数据的分页检索。 在分页功能上,...

    springmvc+hibernate+spring maven案例(包含分页查询)

    Spring MVC、Hibernate 和 Spring 是Java开发中非常流行的三大框架,它们分别用于Web应用的视图控制器、对象关系映射和依赖注入。这个压缩包提供的案例是这三个框架的整合使用,涵盖了基本的CRUD(创建、读取、更新...

    springMVC+spring+ hibernate查询

    Spring MVC 是一个用于构建 Web 应用的模型-视图-控制器(MVC)框架,Spring 提供了依赖注入、AOP(面向切面编程)等核心功能,而 Hibernate 则是 ORM(对象关系映射)框架,简化了数据库操作。 首先,Spring MVC ...

    struts+hibernate 项目

    Hibernate支持事务处理、缓存机制和复杂的查询,提高了开发效率和数据一致性。 在这个“Struts+Hibernate项目”中,用户登录功能是基础,这通常涉及到用户验证和权限控制。开发者可能使用Struts的ActionForm收集...

    基于hibernate的简单留言本

    6. ** Criteria 查询**: Hibernate提供了一种比SQL更面向对象的查询方式,Criteria API可以动态构建查询条件,更加灵活。 7. **事务(Transaction)**: 为了确保数据的一致性,Hibernate支持事务管理。在对数据库...

    STRUTS2+HIBERNATE详细的分页实现代码详细的分页实现代码

    // 将查询结果和总记录数传递给视图 return SUCCESS; } // 省略getter和setter } ``` ### 总结 通过上述步骤和示例代码,我们了解了如何在Struts2和Hibernate框架下实现分页功能。这种实现方式不仅提高了应用...

    springMVC+hibernate3整合

    Spring MVC 和 Hibernate 是两个在Java Web开发中广泛使用的框架,它们分别处理模型-视图-控制器(MVC)架构中的不同部分以及数据持久化。Spring MVC 提供了强大的请求处理和视图管理功能,而 Hibernate 则是 ORM...

    hibernate自动生成Pojo

    1. **打开 Hibernate Configurations 视图**:在 Eclipse 或类似的集成开发环境中,通过 `Window -&gt; Show View -&gt; Other...` 找到 Hibernate Configurations 视图。 2. **添加配置**:在视图空白区域右键选择 `Add ...

    Hibernate_Tools_for_eclipse_HbmTool.rar

    打开Hibernate视图找到Hibernate运行图标下的Hibernate Code Generation Configurations,如果找不到这个图标说明没有在Hibernate视图下。 配置一个新的配置项,输入配置项的名称MyHibernateCode,选择Hibernate ...

    Hibernate做的留言板

    通过将Java类与数据库表关联,Hibernate自动处理SQL查询和结果集的映射,使得开发人员可以更专注于业务逻辑,而不是底层的数据库操作。标签中的"源代码"意味着我们可以深入研究项目的内部工作原理,这对于学习和理解...

    springmvc+hibernate+poi实现mysql数据库简单操作以及导出excel功能

    这些控制器可能包含处理数据库查询、添加、更新或删除数据的方法,通过Service层调用Hibernate的DAO实现具体的数据库操作。 Apache POI是Java中用于读写Microsoft Office格式文件的库,特别是Excel。在这个项目中,...

    Hibernate_Tools_for_Eclipse插件的安装和使用

    3. 在 Hibernate Configuration 视图窗口中,选择要生成的实体类,点击右键,选择 Hibernate Code Generation,选择生成实体类的选项。 4. 等待生成完毕,实体类已经生成完成。 Hibernate_Tools_for_Eclipse 插件是...

Global site tag (gtag.js) - Google Analytics