hibernate不会返回正确的值

时间:2014-06-10 10:06:36

标签: hibernate

我的问题是这个,我在xml中映射了我的项目类,并希望通过get()方法自动获取hibernate的形状对象。问题是我从其他行返回的数据与我要求的不匹配

这是我的类映射Alimento

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 29-may-2014 11:22:30 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="innopckg.Alimento" table="alimento">
        <id name="id" type="int">
            <column name="id_al" />
            <generator class="identity" />
        </id>
        <property name="nombre" type="java.lang.String" >
            <column name="nombre" unique="true"/>
        </property>
        <set name="compuestos" table="compuesto_alimento" lazy="true" inverse="true">
            <key>
                <column name="id_alimento" />

            </key>

            <many-to-many column="id_compuesto" class="innopckg.Compuesto" unique="true"/>
        </set>

        <join table="referencia_alimento" inverse="false" fetch="select" >
            <key >              
                <column name="id_alimento" />
            </key>
            <many-to-one name="ref" class="innopckg.Referencia"
                column="id_referencia" />
            <property name="cantidad" type="double" >
                <column name="cantidad" />
            </property>

        </join>
    </class>
</hibernate-mapping>

这个映射我的类Referencia

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 29-may-2014 11:22:30 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
 <class name="innopckg.Referencia" table="REFERENCIA">
  <id name="id" type="int">
   <column name="id_ref"/>
   <generator class="identity"/>
  </id>
  <property generated="never" lazy="false" name="nombre" type="java.lang.String">
   <column name="nombre" unique="true"/>
  </property>
  <property generated="never" lazy="false" name="peso" type="double">
   <column name="peso"/>
  </property>
  <property generated="never" lazy="false" name="jh" type="double">
   <column name="jh"/>
  </property>
  <property generated="never" lazy="false" name="fh" type="double">
   <column name="fh"/>
  </property>
  <set name="alimentos" table="referencia_alimento"  inverse="false"  access="field">
   <key not-null="true">
    <column name="id_referencia" />

   </key>
   <many-to-many column="id_alimento" unique="true" class="innopckg.Alimento" />
  </set>
 </class>
</hibernate-mapping>

我希望你能帮助我,因为我找不到解决方案

0 个答案:

没有答案