-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Date mapping to oracle date type missing time info
PostPosted: Fri Jun 03, 2005 9:09 am 
Newbie

Joined: Wed Mar 23, 2005 12:48 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.5

Mapping documents:
<property
name="imageDt"
type="date"
update="true"
insert="true"
access="property"
column="IMAGE_DT"
length="7"
not-null="true"
unique="false"
/>


Code between sessionFactory.openSession() and session.close():
// imageDt is mapped to java.util.Date or java.sql.Timestamp
// both yielded the same result

image = new Image();
java.util.Date date = new java.util.Date();
//Timestamp ts = new Timestamp(date.getTime()); // not working either
image.setImageDt(date);
//image.setImageDt(ts);
dao.saveImage(image);


Full stack trace of any exception that occurs:
No exception is thrown. The date saved to db doesn't have time information.


Name and version of the database you are using:
oracle 8.0.6
tried both ojdbc14.jar driver and classes12.zip driver


The generated SQL (show_sql=true):
[] DEBUG [main] AbstractBatcher.log(324) | insert into PROFILE_IMAGES (PROFILE_UID, IMAGE_DT, EXPIRATION_DT, IMAGE_LOCATION, USER_CREATED, DT_CREATED, DT_MODIFIED, IMAGE_UID) values (?, ?, ?, ?, ?, ?, ?, ?)
[] DEBUG [main] AbstractBatcher.getPreparedStatement(378) | preparing statement
[] DEBUG [main] BasicEntityPersister.dehydrate(1612) | Dehydrating entity: [com.choicepoint.hdpc.model.Image#83]
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '530848' to parameter: 1
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '03 June 2005' to parameter: 2
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '03 June 2005' to parameter: 3
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '/tmp/83.bmp' to parameter: 4
[] DEBUG [main] NullableType.nullSafeSet(59) | binding 'chao' to parameter: 5
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '03 June 2005' to parameter: 6
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '03 June 2005' to parameter: 7
[] DEBUG [main] NullableType.nullSafeSet(59) | binding '83' to parameter: 8


Debug level Hibernate log excerpt:
[] DEBUG [main] BatchingBatcher.addToBatch(27) | Adding to batch
[] DEBUG [main] BatchingBatcher.doExecuteBatch(54) | Executing batch size: 1
[] DEBUG [main] BatchingBatcher.checkRowCount(84) | success of batch update unknown: 0
[] DEBUG [main] AbstractBatcher.logClosePreparedStatement(298) | about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[] DEBUG [main] AbstractBatcher.closePreparedStatement(416) | closing statement
[] DEBUG [main] AbstractFlushingEventListener.postFlush(294) | post flush
[] DEBUG [main] SessionImpl.close(269) | closing session
[] DEBUG [main] ConnectionManager.closeConnection(317) | closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
[] DEBUG [main] JDBCContext.afterTransactionCompletion(283) | after transaction completion
[] DEBUG [main] SessionImpl.afterTransactionCompletion(403) | after transaction completion



Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 11:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
type="date" maps this to the java.sql.Date type, which by definition does not contain time information. Use type="timestamp" or type="java.util.Date".


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 7:54 am 
Newbie

Joined: Wed Mar 23, 2005 12:48 pm
Posts: 3
I tried mapping to "java.util.Date" or "timestamp" as you suggested. They both failed and the exception is shown below. I also tried using "Oracle9Dialect" and "OracleDialect", and both gave the same exception.

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update: encountered SQLException [ORA-03115: unsupported network datatype or representation
]; nested exception is java.sql.BatchUpdateException: ORA-03115: unsupported network datatype or representation

java.sql.BatchUpdateException: ORA-03115: unsupported network datatype or representation

at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:460)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4210)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:249)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:313)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:612)
at com.choicepoint.hdpc.dao.hibernate.ImageDAOHibernate.saveImage(ImageDAOHibernate.java:62)
at com.choicepoint.hdpc.dao.ImageDAOTest.testAddImage(ImageDAOTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 7:18 pm 
Newbie

Joined: Tue Sep 27, 2005 7:12 pm
Posts: 2
Location: Santa Cruz, CA
Quote:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update: encountered SQLException [ORA-03115: unsupported network datatype or representation
]; nested exception is java.sql.BatchUpdateException: ORA-03115: unsupported network datatype or representation


I had a similar issue with a java.util.Date object field mapped to an Oracle TIMESTAMP column. My mapping file specified a "timestamp" type, but I was not getting millisecond precision when fetching my object. Upgrading to ojdbc14.jar solved this problem for me.

http://www.oracle.com/technology/softwa ... index.html

p.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.