-->
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.  [ 9 posts ] 
Author Message
 Post subject: Tools-Rev. Eng problem with ORACLE Timestamp mapping
PostPosted: Tue Oct 11, 2005 10:06 pm 
Newbie

Joined: Fri Oct 07, 2005 1:39 am
Posts: 17
Hibernate Tools Version: 3.1.0.alpha5

Hi,
Is there a problem with mapping ORACLE Timestamp (with timezone) fields in Hibernate Tools.
I have the following Table:

Attribute_Test
ATTRIBUTE_ID NOT NULL NUMBER
VALUE VARCHAR2(255)
ANOTHER_DATE TIMESTAMP(6)
MODIFIED_DATE TIMESTAMP(6) WITH TIME ZONE

I am unable to map the MODIFIED_DATE column. It results in the following familiar problem:

hibernate/build.xml:143: org.hibernate.cfg.JDBCBinderException: The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.

I have tried to use a type-mapping construct in the hibernate.reveng.xml. Here it is:
<hibernate-reverse-engineering>
<type-mapping>
<sql-type jdbc-type="TIMESTAMP" hibernate-type="java.lang.String" />
<sql-type jdbc-type="DECIMAL" hibernate-type="long" />
</type-mapping>
<table-filter match-name="ATTRIBUTE_TEST" />
<table-filter match-schema=".*" match-name=".*" exclude="true" />
</hibernate-reverse-engineering>

Note: The recommendation with dealing withese sort of Timestamp variants is to treat them as a String (hence the mapping).

Here is the ant output:
[hibernatetool] INFO - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 -
64bit Production
[hibernatetool] With the Partitioning, OLAP and Data Mining options
[hibernatetool] INFO - JDBC driver: Oracle JDBC driver, version: 10.1.0.4.0
[hibernatetool] DEBUG - returning connection to pool, pool size: 1
[hibernatetool] INFO - Using dialect: org.hibernate.dialect.Oracle9Dialect
[hibernatetool] INFO - Using default transaction strategy (direct JDBC transactions)
[hibernatetool] INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or tra
nsactional second-level cache is not recommended)
[hibernatetool] INFO - Automatic flush during beforeCompletion(): disabled
[hibernatetool] INFO - Automatic session close at end of transaction: disabled
[hibernatetool] INFO - JDBC batch size: 15
[hibernatetool] INFO - JDBC batch updates for versioned data: enabled
[hibernatetool] INFO - Scrollable result sets: enabled
[hibernatetool] DEBUG - Wrap result sets: disabled
[hibernatetool] INFO - JDBC3 getGeneratedKeys(): disabled
[hibernatetool] INFO - Connection release mode: null
[hibernatetool] INFO - Default schema: IDOM
[hibernatetool] INFO - Maximum outer join fetch depth: 1
"ant.out" 107 lines, 8823 characters
[hibernatetool] DEBUG - Finding columns for IDOM.ATTRIBUTE_TEST
[hibernatetool] DEBUG - primary key for org.hibernate.mapping.Table(IDOM.ATTRIBUTE_TEST) -> org.hibernate.m
apping.PrimaryKey(ATTRIBUTE_TEST[org.hibernate.mapping.Column(ATTRIBUTE_ID)]) as SYS_C0029914
[hibernatetool] DEBUG - Calling getExportedKeys on org.hibernate.mapping.Table(IDOM.ATTRIBUTE_TEST)
[hibernatetool] DEBUG - Sql type mismatch for Column org.hibernate.mapping.Column(ATTRIBUTE_ID) between DB
and wanted hibernate type. Sql type set to -5 instead of 3
[hibernatetool] DEBUG - Building property attributeId
[hibernatetool] DEBUG - Cascading attributeId with null
[hibernatetool] DEBUG - Building property value
[hibernatetool] DEBUG - Cascading value with null
[hibernatetool] DEBUG - Sql type mismatch for Column org.hibernate.mapping.Column(ANOTHER_DATE) between DB
and wanted hibernate type. Sql type set to 12 instead of 93
[hibernatetool] DEBUG - Building property anotherDate
[hibernatetool] DEBUG - Cascading anotherDate with null
[hibernatetool] DEBUG - returning connection to pool, pool size: 1


Is this a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 4:02 pm 
Newbie

Joined: Wed Oct 12, 2005 3:59 pm
Posts: 12
Were you able to solve this? I'm having a similar problem, and lack of documentation is killing me... I never had trouble w/ this before alpha5.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 4:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
please show the schema and generated mapping that worked before alpha5 and now breaks...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 5:14 pm 
Newbie

Joined: Wed Oct 12, 2005 3:59 pm
Posts: 12
Scratch that... my problem seems to be stemming from a change to using FLOAT in some cases. I've tried adding the mapping entry in my reveng.xml (is this name a pun, a hidden message ;-)), but that doesn't seem to work.

Let me do some research as I might need to change datatypes anyway to better support my application.

BTW, regarding all the RTFM responses... it's not straight-forward where all the resources are... one needs to look at the Ant manual for the the small bit on reveng.xml there (even though the same information applies to Eclipse Tools), and the DTD hasn't been posted (so one needs to open the hibernate-tools.jar to grab it).

I'll repost if I can't solve this after investigating all of this.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 8:02 pm 
Newbie

Joined: Fri Oct 07, 2005 1:39 am
Posts: 17
Further to my earlier post......
I have discovered that the TIMESTAMP WITH TIME ZONE type is a non-standard type (TIMESTAMPTZ). It is an extension, to the standard SQLTypes. This would explain why the TIMESTAMP mapping is not working.
My question, is if I want to use another mapping, should I be using the numeric value of the TIMESTAMPTZ type - as I don't believe hibernate recognizes this type.
Also, would I be able to map this to the oracle class for this Type (the name of which I can't remember), which in in the JDBC driver:

i.e
<type-mapping>
<sql-type jdbc_type="some number" hibernate.org="some oracle class" />
</type-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 10:31 pm 
Newbie

Joined: Fri Oct 07, 2005 1:39 am
Posts: 17
I have discovered the following:

The SQLType for TIMESTAMPTZ is -101, and the following type-mapping
<sql-type jdbc-type="-101" hibernate-type="oracle.sql.TIMESTAMPTZ" />

will work (in your reveng.file). If you use TIMESTAMPTZ it will not be recognized as it is not a standard SQLType.

P.S. Beware when using the TIMESTAMPTZ type jn JDBC ops, as it creates an extra socket or some similar (See ORACLE Doco.)

Good Luck.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 4:48 pm 
Beginner
Beginner

Joined: Thu Oct 13, 2005 3:40 pm
Posts: 29
I could not even get TIMESTAMP to work using

<type-mapping>
<sql-type jdbc-type="TIMESTAMP" hibernate-type="org.hibernate.type.TimestampType" />
</type-mapping>

even though timestamp is supported out-of-the-box based on Hibernate's 3.0.5 reference guide in section 6.2.2.

I am using Htools 3.1.5 alpha.

How did you get this to work with TIMESTAMP? I got the infamous error

org.hibernate.cfg.JDBCBinderException:The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.


any insights would be greatly appreciated!

Thanks!

Atul


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 7:07 pm 
Newbie

Joined: Fri Oct 07, 2005 1:39 am
Posts: 17
atewari wrote:
I could not even get TIMESTAMP to work using

<type-mapping>
<sql-type jdbc-type="TIMESTAMP" hibernate-type="org.hibernate.type.TimestampType" />
</type-mapping>


How did you get this to work with TIMESTAMP? I got the infamous error

org.hibernate.cfg.JDBCBinderException:The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.


any insights would be greatly appreciated!

Thanks!

Atul


Atul, you're quite right TIMESTAMP is supported 'out-of-the-box' as you say. This means that you should not have to provide a mapping. Are you sure that its the TIMESTAMP field that is the problem? Perhaps you can reproduce the error on a simplified Table with what you preceive is the problem column(s) and post the Table definition.
Also, that latest cvs build will get around this issue and won't cause an Exception. It does this by mapping the unknown type to something other that an Object (I can't rememeber exactly what the type is). But, to work properly with the erroneous Type you will have to find a suitable mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 8:29 pm 
Beginner
Beginner

Joined: Thu Oct 13, 2005 3:40 pm
Posts: 29
The schema for the simple table is

Code:
CREATE TABLE DUMMY_RESULT
(
  LABOR_BUDGET            INTEGER,
  LABOR_SURPLUS_PER_HOUR  NUMBER(10,2),
  SURPLUS_LABOR_AMT       NUMBER(10,2),
  SAVINGS_POOL_BALANCE    NUMBER(10,2),
  NEW_SAVINGS_POOL        NUMBER(10,2),
  STORE_ID                NUMBER(38),
  ALLOCATED_BUDGET        NUMBER(10,2),
  SURPLUS_DUE             NUMBER(10,2),
  TOTAL_LABOR_COST        NUMBER(10,2),
  CREATED_BY VARCHAR2(30) ,
  CREATED_DT TIMESTAMP(6)
)


I will get the latest build, but based on the documentation, I should not have to create a mapping - JDBC-TYPE TIMESTAMP gets mapped to java.sql.Timestamp. I am using Oracle 9i.

I will test with latest build and verify if t works out-of-the-box.

Thanks again for your response!

Atul


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.