Hallo,
beim Versuch eine MySQL-Tabelle auszulesen bekomme ich eine "could not execute query" Exception. Die Exception wird nur erzeugt, wenn die beiden "timestamp-Felder" im Mapping-File eingetragen sind. Ohne diese Felder ist alles OK.
Das Einfügen eines Datensatzes mit "session.save" funktioniert problemlos, AUCH MIT DEN BEIDEN TIMESTAMPS!. Damit kann das Problem nicht am Mapping-File liegen, oder?
Hibernate version:
hibernate3
Mapping documents:
Code:
<?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="de.test.reminder.src.ReminderVO" table="REMINDER.EVENTS">
<id name="id" column="id" type="long">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="beschreibung"/>
<property name="datum"/>
<property name="zeit"/>
<property name="time"/>
<property name="type"/>
<property name="cyclBegin" column="cycl_begin" type="timestamp"/>
<property name="cyclEnde" column="cycl_ende" type="timestamp"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
private List listData() {
try {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
List result = session.createQuery("from ReminderVO").list();
tx.commit();
HibernateUtil.closeSession();
return result;
} catch (HibernateException e) {
throw new RuntimeException(e.getMessage());
}
}
Full stack trace of any exception that occurs:Code:
Hibernate: select remindervo0_.id as id, remindervo0_.name as name0_, remindervo0_.beschreibung as beschrei3_0_, remindervo0_.datum as datum0_, remindervo0_.zeit as zeit0_, remindervo0_.time as time0_, remindervo0_.type as type0_, remindervo0_.cycl_begin as cycl8_0_, remindervo0_.cycl_ende as cycl9_0_ from REMINDER.EVENTS remindervo0_
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: could not execute query
Name and version of the database you are using:MySQL4.1
The generated SQL (show_sql=true):Code:
select remindervo0_.id as id, remindervo0_.name as name0_, remindervo0_.beschreibung as beschrei3_0_, remindervo0_.datum as datum0_, remindervo0_.zeit as zeit0_, remindervo0_.time as time0_, remindervo0_.type as type0_, remindervo0_.cycl_begin as cycl8_0_, remindervo0_.cycl_ende as cycl9_0_ from REMINDER.EVENTS remindervo0_
Vielen Dank
Richard
BTW: Die generierte Query direkt in den "MySQL Query Browser" gepastet funktioniert problemlos!!