-->
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.  [ 3 posts ] 
Author Message
 Post subject: BINARY_FLOAT mapping in Oracle 10g
PostPosted: Mon Sep 19, 2005 3:48 am 
Newbie

Joined: Fri Sep 16, 2005 10:04 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hello, I'm trying to produce POJOs using reverse engineering in hibernate-tools,
and I have encountered some of the problems that were discussed already in many
forum messages.

At the end I have managed to deal with most of the problems, and now I'm able
to create classes from most of the tables that I'm using in an Oracle database 10g.

But one of the table is giving me the usual problem :
Quote:
BUILD FAILED
/Users/formica/Public/COOLTest/build.xml:138: org.hibernate.cfg.JDBCBinderException: The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.


I think the problem is coming from some fields on that table which are of type BINARY_FLOAT.
I'm using oracle jdbc driver ojdbc14_g.jar
that I have downloaded last week from oracle site.

By the way, when turning on DEBUG in log4j I get quite a lot of messages
of the following kind :
Quote:
[hibernatetool] 16401 [main] DEBUG org.hibernate.cfg.JDBCBinder - Sql type mismatch for Column org.hibernate.mapping.Column(IOV_SINCE) between DB and wanted hibernate type. Sql type set to 2 instead of 3


I tried to look around what the numbers (2, 3 , -5, -7,...) means, but I was not able to find any information...where should I look ?

While I was trying to understand the BINARY_FLOAT issue,
I tried to perform a query on that table using a stand-alone program and I managed to retrieve numbers even if there is a "strange" behaviour when asking for metadata information :

Code:
    // Create a Statement
    Statement stmt = conn.createStatement ();
   ResultSet ecal = stmt.executeQuery ("select c.OBJECT_ID , c.CHANNEL_ID , c.CHAN04 from COOLTEST_F0002_IOVS c where ROWNUM < 10");
   ResultSetMetaData rsmd1 = ecal.getMetaData();
   while (ecal.next()) {
      int ncol = rsmd1.getColumnCount();
      for (int i=1;i<=ncol;i++)
       System.out.print(rsmd1.getColumnLabel(i) + "= " + ecal.getString(i) + " "+rsmd1.getColumnClassName(i)+" "+rsmd1.getColumnTypeName(i)+" ");   
      System.out.println();
   }
    ecal.close();


and the print that I get is:

Quote:
OBJECT_ID= 1 java.math.BigDecimal NUMBER CHANNEL_ID= 365032 java.math.BigDecimal NUMBER CHAN04= 21.704052 null BINARY_FLOAT
OBJECT_ID= 2 java.math.BigDecimal NUMBER CHANNEL_ID= 365032 java.math.BigDecimal NUMBER CHAN04= 21.704052 null BINARY_FLOAT


As you can see the function : getColumnClassName(i) does not return any class for BINARY_FLOAT....

Could this be related to my problem with hibernate tool ?
Do you have any hints on how to solve my problem ?

Below I put my reveng.xml file and versions of hibernate that I'm using.

Thanks in advance,

Andrea

PS: thanks a lot for the wonderful job that you are doing with hibernate !!


Hibernate version:
hibernate 3.0.5
hibernate-tools 3.1 alpha5
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd
" >

<hibernate-reverse-engineering>
<type-mapping>
<sql-type jdbc-type="NUMERIC" precision="1" hibernate-type="boolean" />
<sql-type jdbc-type="BIGINT" hibernate-type="long" />
<!--
<sql-type jdbc-type="BIT" hibernate-type="integer" />
<sql-type jdbc-type="TINYINT" hibernate-type="long" />
<sql-type jdbc-type="BIGINT" hibernate-type="long" />
<sql-type jdbc-type="BOOLEAN" hibernate-type="boolean" />
-->
</type-mapping>

<table-filter match-schema="ROTHBERG" match-name="COOLTEST_TAGS" exclude="false"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_NODES_SEQ" exclude="false"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_NODES" exclude="false"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_F0003_IOVS_SEQ" exclude="true"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_F0003_IOVS" exclude="false"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_F0002_IOVS_SEQ" exclude="false"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_F0002_IOVS" exclude="true"/>
<table-filter match-schema="ROTHBERG" match-name="COOLTEST_DB_ATTRIBUTES" />
<table-filter match-schema="ROTHBERG" match-name="CHAM03_TAGS" exclude="true" />
<table-filter match-schema="ROTHBERG" match-name="CHAM03_NODES_SEQ" exclude="true" />
<table-filter match-schema="ROTHBERG" match-name="CHAM03_NODES" exclude="true" />
<table-filter match-schema="ROTHBERG" match-name="ARC_STATEMENT" exclude="true" />
<table-filter match-schema="ROTHBERG" match-name="ARC_SITE" exclude="true" />
<table-filter match-schema="ROTHBERG" match-name="ARC_LOG" exclude="true" />
<table-filter match-schema="ROTHBERG" match-name="ARC_HISTORYPATH" exclude="true" />
<table-filter match-catalog=".*" match-schema=".*" match-name=".*" exclude="true" />
</hibernate-reverse-engineering>

Full stack trace of any exception that occurs:
/Users/formica/Public/COOLTest/build.xml:138: org.hibernate.cfg.JDBCBinderException: The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.

Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 10:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the numbers refer to the constants from java.sql.Types.

BINARY_FLOAT is not a java.sql.Types so you need to find out what sql-type value it is returned as.

in a future release we might need to add support for db specific naming of these types, but until then you need to use the numbers of stick to java.sql.Types

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 6:46 am 
Newbie

Joined: Fri Sep 16, 2005 10:04 am
Posts: 3
Hi Max, thanks for your help, I found the table java.sql.Types and the
related constant field values...

That was very nice for the understanding...sorry for the silly question
about the Types !!!

Then I tried to print (using a standalone program using last oracle
jdbc driver ) the
Code:
ResultSetMetaData.getColumnType(i)


and I got the following int: 100 for my column BINARY_FLOAT

I tried then to add the following mapping in my reveng.xml....

Code:
   <sql-type jdbc-type="100"  hibernate-type="float" />


and .... it worked !!!


Andrea[/code]


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