Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I've got my mapping file, database, POJO and config file all set up. The simple CAT example from Hibernate guide works.
But when I try to access a smalldatetime column in my SQL Server database, I get the error "Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff" I'm not sure why it's expecting a timestamp because the config file, pojo and database all say "date" or "smalldatetime".
Thanks
Hibernate version:
3.0
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mappint DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.rps.monitor.MonitorVisit" table="monitor_visits">
<id name="id" type="int" unsaved-value="null">
<column name="monitor_visit_id" sql-type="int" not-null="true" />
<generator class="identity" />
</id>
<property name="visitDateDraftSubmitted">
<column name="visit_date_draft_submitted" sql-type="date" not-null="false" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
MonitorVisit mv = (MonitorVisit) session.get(MonitorVisit.class, new Integer(555));
System.out.println(mv.getPiPersonID());
Full stack trace of any exception that occurs:Code:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
at java.sql.Timestamp.valueOf(Unknown Source)
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:407)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getTimestamp(JtdsResultSet.java:1116)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getTimestamp(JtdsResultSet.java:1268)
at org.hibernate.type.TimestampType.get(TimestampType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1663)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:877)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:833)
at org.hibernate.loader.Loader.getRow(Loader.java:746)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:290)
at org.hibernate.loader.Loader.doQuery(Loader.java:384)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1255)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:139)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:124)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2453)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:387)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:368)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:249)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:123)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:561)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:556)
at com.rps.monitor.TestMonitorVisit.main(TestMonitorVisit.java:24)
Exception in thread "main"
Name and version of the database you are using:
SQL Server 2000 with the JTDS driver...perhaps a different driver would give better results?
The generated SQL (show_sql=true):
None showing in Eclipse Hibernate console. Don't know how to turn show_sql on yet
Debug level Hibernate log excerpt:
Haven't got logging working yet.