Следующий запрос не возвращает никаких строк. Listmedies = session.createQuery ("from Remedy"). List ();Нет ошибок, но ничего в списке лекарств нет, и в таблице есть строки.
У меня есть 2 таблицы: лекарство и лекарствоПеревод У меня есть следующие файлы карты: лекарство.hbm.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">
<hibernate-mapping>
<class name="com.audiClave.Service.Remedy" table="REMEDY">
<id column="REMEDY_ID" name="remedy_id" type="int">
<generator class="native"/>
</id>
<property generated="never" lazy="false" name="name">
<column name="NAME"/>
</property>
<set
name="remedyTranslations"
lazy="true"
inverse="true"
cascade="save-update">
<key column="REMEDY_ID"/>
<one-to-many class="com.audiClave.Service.RemedyTranslation"/>
</set>
</class>
</hibernate-mapping>
medyTranslation.hbm.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">
<hibernate-mapping>
<class name="com.audiClave.Service.RemedyTranslation" table="REMEDYTRANSLATION">
<id column="REMEDYTRANSLATION_ID" name="remedyTranslation_id" type="int">
<generator class="native"/>
</id>
<many-to-one
name="remedy_id"
column="REMEDY_ID"
class="com.audiClave.Service.Remedy"
not-null="true"
lazy="false" />
<property generated="never" lazy="false" name="name">
<column name="NAME"/>
</property>
<property generated="never" lazy="false" name="language">
<column name="LANGUAGE"/>
</property>
</class>
</hibernate-mapping>
hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/userdata</property>
<property name="connection.username">mysql</property>
<property name="connection.password">???????</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="remedy.hbm.xml"/>
<mapping resource="remedyTranslation.hbm.xml"/>
</session-factory>
</hibernate-configuration>