July 10, 2006 at 10:37 am
Hi,
I'm trying to persist a field of type java.sql.Timestamp to a column of type datetime in sql server 2005. I get an exception :
java.lang.UnsupportedOperationException: cannot perform lookups on timestamps. The field i'm trying to persist is a part of a composite primary key. The detailed exception is as follows:
12:13:55,110 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.UnsupportedOperationException
12:13:55,110 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.UnsupportedOperationException
12:13:55,120 ERROR [[action]] Servlet.service() for servlet action threw exception
java.lang.UnsupportedOperationException: cannot perform lookups on timestamps
at org.hibernate.type.TimestampType.getHashCode(TimestampType.java:98)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:113)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:199)
at org.hibernate.engine.EntityKey.getHashCode(EntityKey.java:65)
at org.hibernate.engine.EntityKey.
at org.hibernate.event.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:135)
at org.hibernate.event.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:106)
at org.hibernate.event.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:180)
at org.hibernate.event.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:31)
at org.hibernate.event.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:169)
at org.hibernate.event.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:25)
at org.hibernate.event.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:65)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:479)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:474)
I have tried these with my other tables and never got an exception. but this is the first time i'm trying timestamp to datetime conversion with a primary key.
Can anyone suggest what could be the reason?
Thanks, Nithya.
July 11, 2006 at 10:25 am
I no sure if the timestamp in java is the same as SQLSERVER timestamp.
in SQL server timestamp is no a date time field. It is used to compare when was the lasttime that a row was updated or inserted. if for java is the same try to use the timestamp data type in SQL SERVER, look for timestamp in the SQL server books online.
hope this help.
July 11, 2006 at 10:49 am
Thanks a lot pedro for the reeponse. Sql server timestamp datatype has a different purpose and cannot be used as a primary key. I'm now thinking to send the timestamp as a string and cast it to datetime. Hopefully it shud work.
July 11, 2006 at 10:50 am
That is correct SQL Server TimeStamp is a derived data type SQL Server uses internally so you need Java datetime to do conversion. Hope this helps.
Kind regards,
Gift Peddie
Kind regards,
Gift Peddie
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply