Hi leute,
Ich habe ein Problem mit einer Postgres Datenbank.
Die Persistenz übernimmt Hibernate und bisher hat auch immer alles funktioniert. Nun muss ich ein Datum speichern und dies wollte ich als Timestamp oder als Date machen.
Mein Problem ist das Hibernate immer diesen Fehler wirft.
Wenn ich die Hibernate.cfg.xml an eine MySQL Datenbank anpasse und das gleiche dort auf eine äquivalente Tabelle ausführe funktioniert es wunderbar also muss es ja an postgres liegen.
Alle andere Abfragen und speicherungen funktionieren bei Postgres.
Hier die Hibernate config :
Hier die Bean :
package de.umkuk.model.bean;
Mapping :
In der Postgres hab ich schon alle Datentypen durch von.
time stamp + timezone, timestamp ohne timezone, date + tz, date ohne tz, time
Und auch in Java schon alles druch von util.Date über sql.Date hin zu Timestamp.
Ich bin echt ratlos.
Java 1.6
neuste hibernate
postgres 8.2.5-1
Vielen Dank
Ich habe ein Problem mit einer Postgres Datenbank.
Die Persistenz übernimmt Hibernate und bisher hat auch immer alles funktioniert. Nun muss ich ein Datum speichern und dies wollte ich als Timestamp oder als Date machen.
Mein Problem ist das Hibernate immer diesen Fehler wirft.
Code:
15:04:43,781 DEBUG SQL:401 - select max(id) from session
Hibernate: select max(id) from session
15:04:43,843 DEBUG SQL:401 - insert into session (room_id, price, fromDate, tillDate, id) values (?, ?, ?, ?, ?)
Hibernate: insert into session (room_id, price, fromDate, tillDate, id) values (?, ?, ?, ?, ?)
15:04:43,859 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: null
15:04:43,859 ERROR JDBCExceptionReporter:78 - Batch-Eintrag 0 insert into session (room_id, price, fromDate, tillDate, id) values (3, 30.0, 2008-02-11 15:04:41.807000 +0100, 2008-02-11 15:04:41.807000 +0100, 1) wurde abgebrochen. Rufen Sie getNextException auf, um die Ursache zu erfahren.
15:04:43,859 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: 42703
15:04:43,859 ERROR JDBCExceptionReporter:78 - ERROR: column "fromdate" of relation "session" does not exist
15:04:43,862 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at de.umkuk.model.access.AbstractPGDAO.endSession(AbstractPGDAO.java:56)
at de.umkuk.model.access.AbstractPGDAO.insert(AbstractPGDAO.java:88)
at de.umkuk.test.TestKlasse.main(TestKlasse.java:38)
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 insert into session (room_id, price, fromDate, tillDate, id) values (3, 30.0, 2008-02-11 15:04:41.807000 +0100, 2008-02-11 15:04:41.807000 +0100, 1) wurde abgebrochen. Rufen Sie getNextException auf, um die Ursache zu erfahren.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2478)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1298)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2540)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 10 more
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
Wenn ich die Hibernate.cfg.xml an eine MySQL Datenbank anpasse und das gleiche dort auf eine äquivalente Tabelle ausführe funktioniert es wunderbar also muss es ja an postgres liegen.
Alle andere Abfragen und speicherungen funktionieren bei Postgres.
Hier die Hibernate config :
Code:
<?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="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/umkuk</property>
<property name="connection.username">low1337</property>
<property name="connection.password">test</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="de/umkuk/model/bean/Mapping/RoomSaison.hbm.xml"/>
</session-factory>
</hibernate-configuration>
package de.umkuk.model.bean;
Code:
import java.sql.Timestamp;
import de.umkuk.model.helper.BeanHelper;
/**
* Mapping Klasse für die Tabelle room_saison
* @author low1337
*
*/
public class RoomSaison extends BeanHelper
{
private int room_id;
private float price;
private Timestamp fromDate;
private Timestamp tillDate;
// hier sind noch getter und Setter !!
}
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.umkuk.model.bean.RoomSaison" table="session">
<id name="id" column="id" >
<generator class="increment"/>
</id>
<property name="room_id" column="room_id"></property>
<property name="price" column="price"></property>
<property name="fromDate" column="fromDate"></property>
<property name="tillDate" column="tillDate"></property>
</class>
</hibernate-mapping>
In der Postgres hab ich schon alle Datentypen durch von.
time stamp + timezone, timestamp ohne timezone, date + tz, date ohne tz, time
Und auch in Java schon alles druch von util.Date über sql.Date hin zu Timestamp.
Ich bin echt ratlos.
Java 1.6
neuste hibernate
postgres 8.2.5-1
Vielen Dank
Code: