-->
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.  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: reverse engg + hibernate tools + eclipse 3.1.0
PostPosted: Mon Dec 12, 2005 4:18 am 
Newbie

Joined: Mon Dec 12, 2005 3:42 am
Posts: 5
[b]Hibernate version:[/b] version 3.05

[b]Mapping documents:[/b] generating hbm and java files using reverse engg.

Taken reference from link -
http://www.hibernate.org/hib_docs/tools ... .html#gen5

I am doing as per the doc but when I do basic setting for atrifact generation and then click on finish to create generate mapping files it shows me error

"org.hibernate.cfg.JDBCBinderException:org.hibernate.mapping.Column(CATALOG_ID) already exists in OLAPSYS.ALL$OLAP2_CATALOGS
"

[b]Full stack trace of any exception that occurs:[/b]


[b]Name and version of the database you are using:[/b] oracle 9i


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
search the forum and learn how to exclude schemas (such as oracles broken system tables) from the reverse engineering.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:35 am 
Newbie

Joined: Mon Dec 12, 2005 3:42 am
Posts: 5
Thanks but do u hve any links which can help me out in doin this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - tools.hibernate.org has pointers to docs that shows how to use a reveng.xml file.

you can also set default schema/catalog to limit the scan for only one schema.

and use the search facility to find more details.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 6:21 am 
Newbie

Joined: Mon Dec 12, 2005 3:42 am
Posts: 5
Thanks once again....
But can you tell me wht could be the main reason behind getting this exception.....
I have tried all search and not able to find the exact cause for the exception.
And is it possible to generate HBM files using hibernate tools plugin only
I have downloaded "hibernate-tools-3.1.0.alpha5"
do i need anything else beside this....


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 6:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as i wrote in the first reply: Oracle has broken system tables which you need to exclude (or simply just only read *one* schema instead of the whole db)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 9:41 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
i think that this error from bug in schema handling
see http://forum.hibernate.org/viewtopic.php?t=951132


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 10:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no it does not.

This error is the same message, but for a different cause.

The problem in this thread is that oracle is really reporting the same column more than once for the same table which occurs for some system tables in oracle - that is what I call "broken oracle system tables"

The problem you are pointing to is something that only have been in the cvs version for about 8 hrs two days ago because of a new feature i added.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 11:15 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
The problem in this thread is that oracle is really reporting the same column more than once for the same table which occurs for some system tables in oracle - that is what I call "broken oracle system tables"


what tables , for example - i do test because i don't believe that oracle do it (i can be problem in jdbc driver, but i test)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 11:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
OLAPSYS.ALL$OLAP2_CATALOGS is one of them.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:03 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
i see what is problem, but i don't sure for workaround
This isn't problem with system tables, than general, but it depend from you naming
for example,

DatabaseMetadata.getColumns("","OLAPSYS","ALL$OLAP2_CATALOGS",null)

will return double column name, but it is for two tables :

ALL$OLAP2_CATALOGS
and
ALL$OLAP2UCATALOGS

sign '_' is escape sequence and tablePattern parameter is pattern (not ture name) and it is return correct result
this isn't bug, but it is problem and i think that it problem exists for every JDBC compliant
database - another database haven't this exotic table name, only

you can check tableName again after getColumns and use only correct table

I think that this will resolve problem

JDBCReader line 446

Code:
if(!tableName.equals(table.getName())) {
   log.debug("Table name " + tableName + " does not match requested " + table.getName() + ". Ignoring column " + columnName + " since it either is invalid or a duplicate" );
      continue;
}


change to :
Code:
if(!tableName.equals(table.getName())) {
    log.debug("Table name " + tableName + " does not match requested " + table.getName() + ". Ignoring column " + columnName + " since it either is invalid or a duplicate" );
    break;
}


regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
doing a break will make it skip every remaining columns - that cannot be right.

Besides where do you see _ as an escape sequence - link ?

If it is truely an escape sequence then we should be able to unescape it otherwise its just still what i call broken (and no, it is only on oracle i get system table names that breaks their names)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:36 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
doing a break will make it skip every remaining columns - that cannot be right.


you have to skip all columns for non-matching table

escape is maybe wrong expression

JDBC requirements for getColumns is that parameter tableName and columnName are pattern
and driver do like query similar this :

select ...
from ...
where table_name like :tablePattern

it do every correct driver and if you have tables , for example

A_C and ABC

thenn getColumns will return every column twice for every correct driver - it is JDBC specification. You haven't problem with another database because it haven't similar table names

tools have to worry about this or you will have potential wrong results for database

You can think what is happen when tables A_C and ABC haven't same column names - then you will not get error, but mapping will be wrong


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 4:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well your fix definitly doesnt fix it since it skips valid columns.

you might be right about _ is a wildcard in some cases, I thought it only reacted to % ...guess i'll have to find a way to quote it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 5:00 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Max

_ is for one character and % is for any number of characters

this is true workaround (JDBCReader.java line 446-491)

Code:
if(tableName.equals(table.getName())) {         
            //String columnDefaultValue = columnRs.getString("COLUMN_DEF"); TODO: only read if have a way to avoid issues with clobs/lobs and similar
            // if columnNoNulls or columnNullableUnknown assume "not nullable"
            boolean isNullable = (DatabaseMetaData.columnNullable == ((Integer)columnRs.get("NULLABLE")).intValue() );
            int size = ((Integer)columnRs.get("COLUMN_SIZE")).intValue();
            int decimalDigits = ((Integer)columnRs.get("DECIMAL_DIGITS")).intValue();
            
            Column column = new Column();
            column.setName(quote(columnName));
            Column existing = table.getColumn(column);
            if(existing!=null) {
               // TODO: should we just pick it up and fill it up with whatever we get from the db instead ?
               throw new JDBCBinderException(column + " already exists in " + qualify);
            }
                        
            //TODO: column.setSqlType(sqlTypeName); //this does not work 'cos the precision/scale/length are not retured in TYPE_NAME
            //column.setSqlType(sqlTypeName);
            column.setComment(comment);
            column.setSqlTypeCode(new Integer(sqlType) );
                if(intBounds(size) ) {
                   if(JDBCToHibernateTypeHelper.typeHasLength(sqlType) ) {
                      column.setLength(size);
                   }
                   if(JDBCToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
                      column.setPrecision(size);
                   }
            }
                if(intBounds(decimalDigits) ) {
                   if(JDBCToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
                      column.setScale(decimalDigits);
                   }
            }
            
            column.setNullable(isNullable);

            // columnDefaultValue is useless for Hibernate
            // isIndexed  (available via Indexes)
            // unique - detected when getting indexes
            // isPk - detected when finding primary keys            
            
            table.addColumn(column);
} else {
            log.debug("Table name " + tableName + " does not match requested " + table.getName() + ". Ignoring column " + columnName + " since it either is invalid or a duplicate" );
   }



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 19 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.