-->
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: Cannot reverse engineer Oracle db: Database schema blank
PostPosted: Sun Oct 24, 2010 5:28 pm 
Newbie

Joined: Sun Oct 24, 2010 5:17 pm
Posts: 2
I am trying to reverse engineer an Oracle 10 database to create Java objects. Everything seems fine until I try to create reveng.xml: the progress bar says "Fetching children of Database" for half a minute before finishing with no entries in the Database schema table. Below is my hibernate.cfg.xml file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="SessionFactory">
  <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  <property name="hibernate.connection.password">xxxx</property>
  <property name="hibernate.connection.url">jdbc:oracle:thin:@IPAddress:1521:XE</property>
  <property name="hibernate.connection.username">USER</property>
  <property name="hibernate.default_schema">USER</property>
  <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
</session-factory
</hibernate-configuration>


I'm not sure what is wrong, although I do not know what the default_schema value should be or how to find out what it should be.
Thanks.


Top
 Profile  
 
 Post subject: Re: Cannot reverse engineer Oracle db: Database schema blank
PostPosted: Mon Oct 25, 2010 7:24 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
default_schema should be the same as user name.
Unless, of course, you wish to log in to Oracle with one user name and access another user's tables (this is commonly done to enforce read/write constraints).

The wait is normal. Oracle is extremely slow when providing metadata, for whatever reasons.

Do you have a schema-selection clause in hibernate.reveng.xml? The Oracle dialect code needs that, the default doesn't work (one of the stumbling blocks that I hit).
Make sure to use a table-filter as well, a database with a few hundred tables requires ten minutes or so to produce the list of tables. I found this to be unbearably slow and have eventually resorted to explicitly listing each and every table that I want reverse engineered.

Here's the basic structure of my hibernate.reveng.xml file:
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>

  <schema-selection match-schema="USERNAME" />
  <type-mapping>
    ...
  </type-mapping>
  <table-filter match-name="SOME_TABLE_1" />
  ...
  <table-filter match-name="SOME_TABLE_N" />
  <table name="SOME_TABLE_1">
    <column
      name="FIELD_1"
      type="com.my.company.lib.usertypes.YN_boolean">
      <meta attribute="default-value">false</meta>
    </column>
    <column name="SOME_DATE_FIELD">
      <meta attribute="default-value">new java.sql.Date (new java.util.GregorianCalendar (9999, 11, 31).getTimeInMillis ())</meta>
    </column>
    <column name="VERSION"
      type="long" />
    ...
    <foreign-key foreign-table="USER" constraint-name="fk_table1_user">
      <column-ref local-column="T1USER" foreign-column="USID" />
      <many-to-one />
      <set exclude="true" />
    </foreign-key>
    ...
  </table>
  ...
</hibernate-reverse-engineering>


As you can see, I'm explicitly specifying default values. These need to be kept in sync with the database - it would be nicer if Hibernate Tools could reverse engineer defaults, but it's hard because at least Oracle returns column defaults as SQL expressions in String form.

I'm also explicitly specifying lots of user types.
This allows me to set things up so that I'll get a type error whenever the database schema changes in incompatible ways, but it also burdens me with specifying user types on roughly 50% of any table's columns. (I think it's worth the effort for the project I'm in, since setting up a unit test would be roughly the same or a little more effort, but that's just the way I work.)


Top
 Profile  
 
 Post subject: Re: Cannot reverse engineer Oracle db: Database schema blank
PostPosted: Tue Oct 26, 2010 2:02 am 
Newbie

Joined: Sun Oct 24, 2010 5:17 pm
Posts: 2
I got it to run. It turns out that there was an issue with the firewall. Thanks for your help anyway.


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.