-->
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.  [ 10 posts ] 
Author Message
 Post subject: NUMERIC to long during reverse engineering
PostPosted: Tue Sep 27, 2005 3:04 pm 
Newbie

Joined: Sat Jun 26, 2004 6:01 pm
Posts: 6
Hello,
I'm trying to reverse engineer an existing database schema. To start with, I'm using only one table(PYMT_STAT).

problem:
PymtStat.hbm.xml and PymtStat.java file still refers to big decimal instead of long (even though hibernate.reveng.xml refers to long as given below)

In the part of log file content given below there is an message as follows:
Sql type mismatch for Column org.hibernate.mapping.Column(PYMT_STAT_KEY) between DB and wanted hibernate type. Sql type set to 2 instead of 3

In would appreciate any help in this issue.

Also, during the reverse engineering process PymtStat.hbm.xml contains
<generator class="assigned" />. I would like to know is there any settings I can perform the use generator class="sequence" etc. because In our oracle settings we are using nextval to get primary key values.

with ddl shown below:

CREATE TABLE PYMT_STAT
(
PYMT_STAT_KEY NUMBER NOT NULL,
PYMT_STAT_NM VARCHAR2(40 BYTE),
CRTE_DT DATE,
CRTE_BY_USER_ID VARCHAR2(30 BYTE),
LAST_UPDT_DT DATE,
LAST_UPDT_USER_ID VARCHAR2(30 BYTE)
)
TABLESPACE ...
NOPARALLEL;

CREATE UNIQUE INDEX PYMT_STAT_PKIDX ON PYMT_STAT
(PYMT_STAT_KEY)


java version and tools used:
jdk 1.4.2, hibernate 3.1 beta 3 and hibernate tools-3.1.0.alpha5, ojdbc14.jar(from oracle)


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
<type-mapping>
<sql-type jdbc-type="NUMERIC" hibernate-type="long" />
</type-mapping>
<table-filter match-schema="TEST" match-name="PYMT_STAT" exclude="false" />
<table-filter match-schema=".*" match-name=".*" exclude="true" />
</hibernate-reverse-engineering>


Hibernate version:
hibernate 3.1 beta 3 and hibernate tools-3.1.0.alpha5
Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.xyz.PymtStat" table="PYMT_STAT" schema="TEST">
<id name="pymtStatKey" type="big_decimal">
<column name="PYMT_STAT_KEY" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="pymtStatNm" type="string">
<column name="PYMT_STAT_NM" length="40" />
</property>
<property name="crteDt" type="date">
<column name="CRTE_DT" length="7" />
</property>
<property name="crteByUserId" type="string">
<column name="CRTE_BY_USER_ID" length="30" />
</property>
<property name="lastUpdtDt" type="date">
<column name="LAST_UPDT_DT" length="7" />
</property>
<property name="lastUpdtUserId" type="string">
<column name="LAST_UPDT_USER_ID" length="30" />
</property>
</class>
</hibernate-mapping>

generated java code:

public class PymtStat implements java.io.Serializable {

// Fields

private java.math.BigDecimal pymtStatKey;
private String pymtStatNm;
private Date crteDt;
private String crteByUserId;
private Date lastUpdtDt;
private String lastUpdtUserId;


// Constructors

/** default constructor */
public PymtStat() {
}

/** constructor with id */
public PymtStat(java.math.BigDecimal pymtStatKey) {
this.pymtStatKey = pymtStatKey;
}




// Property accessors

/**
*
*/
public java.math.BigDecimal getPymtStatKey() {
return this.pymtStatKey;
}

public void setPymtStatKey(java.math.BigDecimal pymtStatKey) {
this.pymtStatKey = pymtStatKey;
}
...
...
.
.
.
...
}


Name and version of the database you are using:
oracle 9

Debug level Hibernate log excerpt:

13:24:48,519 DEBUG JDBCBinder:310 - primary key for org.hibernate.mapping.Table(TEST.PYMT_STAT) -> org.hibernate.mapping.PrimaryKey(PYMT_STAT[org.hibernate.mapping.Column(PYMT_STAT_KEY)]) as PYMT_STAT_PK
13:24:48,569 DEBUG Project:159 - Finding class oracle.net.ns.Message11
13:24:48,573 DEBUG Project:159 - Loaded from /apps/projects/wsClaims/lib/ojdbc14.jar oracle/net/ns/Message11.class
13:24:48,578 DEBUG Project:159 - Finding class oracle.net.ns.Message
13:24:48,582 DEBUG Project:159 - Loaded from /apps/projects/wsClaims/lib/ojdbc14.jar oracle/net/ns/Message.class
13:24:48,586 DEBUG Project:159 - Class oracle.net.ns.Message loaded from ant loader (parentFirst)
13:24:48,593 DEBUG Project:159 - Class oracle.net.ns.Message11 loaded from ant loader (parentFirst)
13:24:48,599 DEBUG Project:159 - Class java.util.MissingResourceException loaded from parent loader (parentFirst)
13:24:48,604 WARN JDBCBinder:609 - Exception while trying to get indexinfo on TEST.PYMT_STAT=ORA-01031: insufficient privileges

13:24:48,609 DEBUG JDBCBinder:87 - Calling getExportedKeys on org.hibernate.mapping.Table(TEST.PYMT_STAT)
13:24:48,639 DEBUG JDBCBinder:101 - foreign key name: AMT_PYMT_STAT_FK
13:24:48,642 DEBUG JDBCBinder:106 - Foreign key AMT_PYMT_STAT_FK references unknown or filtered table AMT


13:24:48,950 DEBUG JDBCBinder:458 - Sql type mismatch for Column org.hibernate.mapping.Column(PYMT_STAT_KEY) between DB and wanted hibernate type. Sql type set to 2 instead of 3


Top
 Profile  
 
 Post subject: not work
PostPosted: Wed Dec 07, 2005 12:56 pm 
Newbie

Joined: Wed Dec 07, 2005 11:55 am
Posts: 5
no matter I use any of this below, not work:

<sql-type jdbc-type="NUMERIC" precision='9' scale="0" hibernate-type="long" />

<sql-type jdbc-type="NUMERIC" precision='9' scale="0" hibernate-type="int" />

only mapping to java.lang.Integer

I think Max should give a detail doc for this or give a long working reveng.xml file.


Top
 Profile  
 
 Post subject: I saw the source codes
PostPosted: Wed Dec 07, 2005 2:45 pm 
Newbie

Joined: Wed Dec 07, 2005 11:55 am
Posts: 5
in the source code JDBCToHibernateTypeHelper.getPreferredHibernateType()

default will :
if (precision == 1) {
// NUMERIC(1) is a often used idiom for storing boolean thus providing it out of the box.
return "boolean";
}
else if (precision < 3) {
return "byte";
}
else if (precision < 5) {
return "short";
}
else if (precision < 10) {
return "integer";
}
else if (precision < 19) {
return "long";
}
else {
return "big_decimal";
}


So you will see that you logic will be shortcut !

Impl your DelegatingReverseEngineeringStrategy instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 4:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh ? That method is the *last* thing to be called if no other strategy matches!

btw. please try with a nightly build and let me know if it still fails...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Same Issue
PostPosted: Fri Dec 30, 2005 9:17 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

I have the same problem using beta2 of the hibernate tools. I am using:

<table schema="SCHEMA_NAME" name="TABLE_NAME" >
<column name="COLUMN_NAME" property="depthNum" type="big_decimal" />
</table>

As far as I can tell no errors generated. Also, the data type in the oracle database is NUMBER column size is 10. Pehaps hibernate tools will not allow you to set to big_decimal if there is no scale set in the database? In other words NUMBER(10,2) vs NUMBER??

Thanks for your previous help.

-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 31, 2005 4:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
enable debug logging and see what it does with that specific column

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Oracle NUMBER type Conversion to java type
PostPosted: Tue Jan 03, 2006 1:19 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Hi Max,

Thanks for the reply. How do I enable debugging for Hibernate Tools. When I do that where is the debug info placed? In a file soemwhere?

Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 1:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look in the docs for logging.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: NUMERIC TO LONG
PostPosted: Tue Jan 03, 2006 6:38 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Thanks Max,

Got logging working but now warn or error in the log. Also, no mention of numeric or integer in log. Seems as if overide not working no matter what I do.

Will try some more tests but will take different tack to solve problem.

Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 1:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the notice is at DEBUG level

_________________
Max
Don't forget to rate


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