Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未使用Hibernate映射类_Java_Hibernate_Orm - Fatal编程技术网

Java 未使用Hibernate映射类

Java 未使用Hibernate映射类,java,hibernate,orm,Java,Hibernate,Orm,我得到了一个带有映射对象的Hibernate应用程序,问题是当我执行HSQL查询时 org.springframework.orm.hibernate3.HibernateQueryException: DescargasTienda is n ot mapped [from DescargasTienda where fecha = ? and market = ?]; nested exceptio n is org.hibernate.hql.ast.QuerySyntaxExceptio

我得到了一个带有映射对象的Hibernate应用程序,问题是当我执行HSQL查询时

org.springframework.orm.hibernate3.HibernateQueryException: DescargasTienda is n
ot mapped [from DescargasTienda where fecha = ? and market = ?]; nested exceptio
n is org.hibernate.hql.ast.QuerySyntaxException: DescargasTienda is not mapped [
from DescargasTienda where fecha = ? and market = ?]
        at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHiberna
teAccessException(SessionFactoryUtils.java:660)
        at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernate
AccessException(HibernateAccessor.java:412)
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(Hibern
ateTemplate.java:411)
        at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativ
eSession(HibernateTemplate.java:374)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTe
mplate.java:912)
        at com.proximate.www.dashmate.dao.impl.DescargasTiendaDAOImpl.insert(Des
cargasTiendaDAOImpl.java:21)
        at com.proximate.www.dashmate.dao.impl.DescargasTiendaDAOImpl.insert(Des
cargasTiendaDAOImpl.java:15)
这是它引发异常的代码:

@Override
public void insert(DescargasTienda o) {
    // TODO Auto-generated method stub
    if(getHibernateTemplate().find("from DescargasTienda where fecha = ? and market = ?", o.getFecha(), o.getMarket()).isEmpty()){
        getHibernateTemplate().save(o); 
    }
}
这是我的hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">update</property>
        <mapping resource="mappings/DescargasTienda.hbm.xml" /> 
    </session-factory>
</hibernate-configuration>
那么,我的代码中有什么错误导致我不断得到未映射异常??
提前谢谢。

我设法解决了这个问题。我忘了提到我有一个主项目,它依赖于另一个项目,所以如果我在主项目中创建一个hibernate.cfg.xml;它会覆盖项目中的hibernate.cfg.xml,因为它具有依赖项。因此,在我的主要项目中,我没有服务器说我缺少的映射:)

启动应用程序时,您是否收到任何错误或警告?是否有其他正确映射的实体?如果没有,请确保应用了映射。我设法解决了问题。我忘了提到我有一个主项目,它依赖于另一个项目,所以如果我在主项目中创建一个hibernate.cfg.xml;它会覆盖项目中的hibernate.cfg.xml,因为它具有依赖项。因此,在我的主要项目中,我没有服务器说我缺少的映射:)
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 6/01/2011 05:14:47 PM by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
    <class name="com.proximate.www.dashmate.model.DescargasTienda" table="descargas_tienda">
        <id name="id" type="integer">
            <column name="id"  />
            <generator class="native" />
        </id>
        <property name="market" type="string">
            <column name="market" />
        </property>
        <property name="descargas" type="integer">
            <column name="descargas" />
        </property>
        <property name="actualizaciones" type="integer">
            <column name="actualizaciones" />
        </property>
        <property name="fecha" type="java.sql.Date">
            <column name="fecha_actualizacion" default="CURRENT_DATE"/>
        </property>
    </class>    
</hibernate-mapping>
package com.proximate.www.dashmate.model;

public class DescargasTienda {

    private int id;
    private String market;
    private int descargas;
    private int actualizaciones;
    private int porcentaje;
    private boolean subida;

    private java.sql.Date fecha;
    public int getId() {
        return id;
    }
    public String getMarket() {
        return market;
    }
    public int getDescargas() {
        return descargas;
    }
    public int getActualizaciones() {
        return actualizaciones;
    }
    public java.sql.Date getFecha() {
        return fecha;
    }
    public void setId(int id) {
        this.id = id;
    }
    public void setMarket(String market) {
        this.market = market;
    }
    public void setDescargas(int descargas) {
        this.descargas = descargas;
    }
    public void setActualizaciones(int actualizaciones) {
        this.actualizaciones = actualizaciones;
    }
    public void setFecha(java.sql.Date fecha) {
        this.fecha = fecha;
    }

    public int getPorcentaje() {
        return porcentaje;
    }
    public boolean isSubida() {
        return subida;
    }
    public void setPorcentaje(int porcentaje) {
        this.porcentaje = porcentaje;
    }
    public void setSubida(boolean subida) {
        this.subida = subida;
    }
    @Override
    public String toString() {
        return "DescargasTienda [id=" + id + ", market=" + market
                + ", descargas=" + descargas + ", actualizaciones="
                + actualizaciones + ", porcentaje=" + porcentaje + ", subida="
                + subida + ", fecha=" + fecha + "]";
    }

}