-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: reveng.xml documentation
PostPosted: Tue Oct 04, 2005 8:26 am 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1beta3
Hibernate Tools version:3.5alpha5
Name and version of the database you are using:Oracle 9i

I'm trying to figure out how to configure my reveng.xml file to properly reverse engineer my schema, but I cannot find any documentation for that file. The best I can find is this: http://www.hibernate.org/hib_docs/tools ... html#gen12

But that isn't documentation. That's just a very limited example.

Can someone point me to actual documentation that explains topics like
    Valid values for 'hibernate-type' in type mappings

    How to properly use table-filters so you only reverse engineer the tables you expect to.


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 8:52 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
have a look on the dtd wich is in the hibernatetools package
org/hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Hi,

Valid values for hibernate-type ? Any hibernate type.

How to properly use table-filters so you only reverse engineer the tables you expect to ? What tables do you expect it to reverse engineer when you point the tool to a database - my reasoning is "everything", but apparently users assume "nothing"....

The examples in what you dont call documentation shows how to include and exclude tables....what is missing from that ? (im asking seriously here)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 1:42 pm 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
By "any hibernate type" I assume you mean any of the fields defined in org.hibernate.Hibernate?

Normally, as you suggested, I would assume that the tool would try to reverse engineer only the tables that I explicitly tell it to. However I have read other posts in the forum that corrected that misconception and I now know that to simulate this behavior you must place the following line at the end of your table filters:
Code:
<table-filter match-schema=".*" match-name=".*" exclude="true"/>


For Example, if I only want ONE table to be mapped, I should put this in my reveng.xml:
Code:
<table-filter match-schema="WEBUSER" match-name="PRODUCT_EULA"/>
<table-filter match-schema=".*" match-name=".*" exclude="true"/>


Please tell me if I'm still laboring under a misunderstanding, because this is where I'm getting confused. That table I'm trying to reverse engineer in the example above gets the popular JDBCBinderException "The type java.lang.Object spans multiple columns."

Now this table has only 3 columns and jdbc returns their types as 2, 12, and 2005. That's java.sql.Types NUMERIC, VARCHAR, and CLOB.

According to your post here:
http://forum.hibernate.org/viewtopic.ph ... s&start=45
those three types are all supported by the JDBCToHibernateTypeHelper and shouldn't even need any type-mappings. But I get the exception anyway, and that leads me to believe the tool is looking at more than just the one table.


Top
 Profile  
 
 Post subject: Just so you know ...
PostPosted: Tue Oct 04, 2005 2:17 pm 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
I'm running the reverse engineering tool from the eclipse plugin. I'm still working on getting DEBUG messages to appear in the log.


Top
 Profile  
 
 Post subject: Re: Just so you know ...
PostPosted: Tue Oct 04, 2005 5:18 pm 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
bgoodwin wrote:
... I'm still working on getting DEBUG messages to appear in the log.

Ok I got verbose logging. It helped a bit. The tool really is only looking at the one table. Unfortunately, that means that the tool isn't properly reverse engineering the only table I've told it about. Here's the reveng.xml, ddl for the table, and the log leading up to the exception. . .

DDL:
Code:
CREATE TABLE PRODUCT_EULA
(
  PRODUCT_EULA_ID  NUMBER                       NOT NULL,
  NAME             VARCHAR2(50 BYTE)            NOT NULL,
  TEXT             CLOB                         NOT NULL
)

reveng.xml:
Code:
<?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" scale="0" hibernate-type="big_integer"/>
        <sql-type jdbc-type="NUMERIC" hibernate-type="big_decimal"/>
        <sql-type jdbc-type="CLOB" hibernate-type="clob"/>
        <sql-type jdbc-type="VARCHAR" hibernate-type="string"/>
    </type-mapping>
    <table-filter match-schema="WEBUSER" match-name="PRODUCT_EULA" />
    <table-filter match-catalog=".*" match-schema=".*" match-name=".*" exclude="true" />
</hibernate-reverse-engineering>

LOG:
Code:
17:02:12,381 DEBUG JDBCBinder:382 - Finding columns for WEBUSER.PRODUCT_EULA
17:02:12,474 DEBUG JDBCBinder:310 - primary key for org.hibernate.mapping.Table(WEBUSER.PRODUCT_EULA) -> org.hibernate.mapping.PrimaryKey(PRO
DUCT_EULA[org.hibernate.mapping.Column(PRODUCT_EULA_ID)]) as PK_PRODUCT_EULA
17:02:13,459 DEBUG JDBCBinder:87 - Calling getExportedKeys on org.hibernate.mapping.Table(WEBUSER.PRODUCT_EULA)
17:02:13,537 DEBUG JDBCBinder:101 - foreign key name: FK_PRODUCT_PRODUCT_EULA_ID
17:02:13,537 DEBUG JDBCBinder:106 - Foreign key FK_PRODUCT_PRODUCT_EULA_ID references unknown or filtered table PRODUCT
17:02:13,537 DEBUG JDBCBinder:101 - foreign key name: FK_PROD_VER_PRODUCT_EULA_ID
17:02:13,537 DEBUG JDBCBinder:106 - Foreign key FK_PROD_VER_PRODUCT_EULA_ID references unknown or filtered table PRODUCT_VERSION
17:02:13,537 DEBUG JDBCBinder:458 - Sql type mismatch for Column org.hibernate.mapping.Column(PRODUCT_EULA_ID) between DB and wanted hibernat
e type. Sql type set to 2 instead of 3
17:02:13,537 DEBUG JDBCBinder:656 - Building property productEulaId
17:02:13,537 DEBUG JDBCBinder:666 - Cascading productEulaId with null
17:02:13,537 DEBUG JDBCBinder:656 - Building property name
17:02:13,537 DEBUG JDBCBinder:666 - Cascading name with null
17:02:13,537 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1

!ENTRY org.hibernate.eclipse.console 4 4 2005-10-04 17:02:13.537
!MESSAGE Error under artifact generation
!STACK 0
org.hibernate.cfg.JDBCBinderException: The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.

        at org.hibernate.cfg.JDBCBinder.guessAndAlignType(JDBCBinder.java:453)
        at org.hibernate.cfg.JDBCBinder.bindColumnToSimpleValue(JDBCBinder.java:403)
        at org.hibernate.cfg.JDBCBinder.bindBasicProperty(JDBCBinder.java:395)
        at org.hibernate.cfg.JDBCBinder.bindColumnsToProperties(JDBCBinder.java:380)
        at org.hibernate.cfg.JDBCBinder.createPersistentClasses(JDBCBinder.java:163)
        at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:91)
        at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
        at org.hibernate.eclipse.console.wizards.ArtifactGeneratorWizard$3.execute(ArtifactGeneratorWizard.java:249)
        at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
        at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:71)
        at org.hibernate.eclipse.console.wizards.ArtifactGeneratorWizard.buildConfiguration(ArtifactGeneratorWizard.java:246)
        at org.hibernate.eclipse.console.wizards.ArtifactGeneratorWizard.doFinish(ArtifactGeneratorWizard.java:165)
        at org.hibernate.eclipse.console.wizards.ArtifactGeneratorWizard.access$0(ArtifactGeneratorWizard.java:133)
        at org.hibernate.eclipse.console.wizards.ArtifactGeneratorWizard$1.run(ArtifactGeneratorWizard.java:99)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 1:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i havent checkked wether those numerics are offically java.sql.Types values but in any case you can just put that numeric value as the sql-type and see if that helps.

And regarding hibernate type, yes its every hibernate type that you can find in hibernate and all the usertypes you would like to use too.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Eureka?
PostPosted: Wed Oct 05, 2005 8:44 am 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
I think I have tracked this down to a bug in the oracle jdbc driver.

As you will note in my DDL snippet above, I didn't define a precision on the CLOB. In this case oracle-db will return 4294967295 (that's 2^32 -1) when the precision of the column is requested. This number is obviously not representable by a java int because they're signed. If you call getMetaData().getPrecision() on a CLOB column defined this way, the oracle JDBC driver will just dump the string "4294967295" straight into Integer.parseInt() which promptly throws a NumberFormatException. Nice of Oracle not to ...idunno... catch that exception. This problem is well documented in the oracle forums going back to 2003. Nice of Oracle not to ...idunno... fix the problem.

So it makes sense that the reverse engineering tool would misbehave here. I've downloaded what I believe to be the latest driver and it still has this problem. The oracle site is less than navigable so I might not have really gotten the latest one. If anyone knows that this problem has been fixed, please tell me where the newest oracle jdbc driver is.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 10:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
do you get the numberformatexception somewhere ? ...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 11:15 am 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
max wrote:
do you get the numberformatexception somewhere ? ...

I didn't see NumberFormatException anywhere in the eclipse log. However, as you can see from the log snippet above it successfully processes the NUMERIC and the VARCHAR columns but then fails before logging anything about the CLOB. Also, I can successfully run the tool on tables that have NUMERICS and VARCHARS but no CLOB. I know the folly of making assumptions, but I can only infer that the CLOB is where the reverse engineering tool is having a problem.

I wrote a small utility earlier to get the returned SQL types of the three columns for that table (that's how I came up with the 2, 12, and 2005 types). I modified that utility to get the precision too. That's where I get the NumberFormatException.

Is there a way I can configure the tool to send OracleDatabaseMetaData.setGetLobPrecision(false);? That will make getPrecision() return -1 for *lobs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 11:17 am 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
max wrote:
i havent checkked wether those numerics are offically java.sql.Types values but in any case you can just put that numeric value as the sql-type and see if that helps.

Tried this. Still failed in the manner logged above.

I also tried having no type-mappings at all. Still failed in the same manner logged above.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 3:26 pm 
Beginner
Beginner

Joined: Tue Oct 04, 2005 8:09 am
Posts: 22
Location: Atlanta, USA
Everyone disregard my theory that the NumberFormatException for finding *LOB precision was causing the JDBCBinderException with oracle.

Thanks to discussions on this thread:
http://forum.hibernate.org/viewtopic.ph ... c&start=75
It seems that the reverse engineering tool is using a different method of discovering the precision of *LOBs. The tool's method (unlike mine) gets a number instead of an exception. For anyone interested in the difference between the methods, it is discussed on the other thread.

Now looking at the following log snippet (A clip from the one I posted above):
Code:
17:02:13,537 DEBUG JDBCBinder:656 - Building property productEulaId
17:02:13,537 DEBUG JDBCBinder:666 - Cascading productEulaId with null
17:02:13,537 DEBUG JDBCBinder:656 - Building property name
17:02:13,537 DEBUG JDBCBinder:666 - Cascading name with null
17:02:13,537 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1

!ENTRY org.hibernate.eclipse.console 4 4 2005-10-04 17:02:13.537
!MESSAGE Error under artifact generation
!STACK 0
org.hibernate.cfg.JDBCBinderException: The type java.lang.Object spans multiple columns. Only single column types allowed for single columns.

It looks like JDBCBinder successfully maps the product_eula_id column, then successfully maps the name column. Then fails when trying to map the only remaining column in the table: the text column which is a CLOB.

Can someone familiar with the code tell me if this interpretation of the log is correct? (I can't connect to sourceforge cvs from work to get the source myself)

If the interpretation is correct, then does anyone know why the tool is failing on the CLOB?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 3:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
try the new tools when its release soon (or use the cvs)

I have hopefully fixed/made this much easier to avoid and if it occurs track down.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Just so you know ...
PostPosted: Tue Oct 11, 2005 2:39 am 
Newbie

Joined: Fri Oct 07, 2005 1:39 am
Posts: 17
bgoodwin wrote:
bgoodwin wrote:
... I'm still working on getting DEBUG messages to appear in the log.

Ok I got verbose logging. It helped a bit. The tool really is only looking at


I have struggled for the last two days trying unsuccessfully to get eclipse to show verbose output when using the Hibernate Tools Plugin. Can you share with me how excatly you got this to work.
I have tried to manipulate log4j.prperties as specified by max, but it still doesn't work.

I am thinking about creating an ant task for the Hibernate Tools and running from within eclipse.


Top
 Profile  
 
 Post subject: Re: Just so you know ...
PostPosted: Tue Oct 11, 2005 2:41 am 
Newbie

Joined: Fri Oct 07, 2005 1:39 am
Posts: 17
bgoodwin wrote:
bgoodwin wrote:
... I'm still working on getting DEBUG messages to appear in the log.

Ok I got verbose logging. It helped a bit. The tool really is only looking at


I have struggled for the last two days trying unsuccessfully to get eclipse to show verbose output when using the Hibernate Tools Plugin. Can you share with me how excatly you got this to work.
I have tried to manipulate log4j.prperties as specified by max, but it still doesn't work.

I am thinking about creating an ant task for the Hibernate Tools and running from within eclipse.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 17 posts ]  Go to page 1, 2  Next

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.