-->
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.  [ 5 posts ] 
Author Message
 Post subject: Java persistence with Hibernate, chapt. 2, reveng sample
PostPosted: Mon Jul 02, 2007 9:28 am 
Newbie

Joined: Fri Jun 29, 2007 5:59 am
Posts: 4
Hi,
I have a strange problem with the reveng example in the sample chapter of the Java persistence with Hibernate book.
I'm trying to use Hibernate with Oracle. I went through all of the previous examples in this chapter and modified them to use an Oracle database in which I had created a similar table (Messages) -- and all previous examples (native Hibernate, JPA, EJB-3) worked seamlessly with Oracle as well as with HSQLDB.

My problem with the reveng example is that it does not generate anything but the hibernate.cfg.xml file. No exception was thrown.

I only modified two files in the whole example.
I simplified the reveng.xml file and as expected it still worked fine with HSQLDB (of course producing different results):
Code:
<?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>
    <table-filter match-name=".*" package="hello"/>
</hibernate-reverse-engineering>


And I replaced the db.properties file with this:
Code:
hibernate.dialect = org.hibernate.dialect.OracleDialect
hibernate.connection.driver_class = oracle.jdbc.driver.OracleDriver
hibernate.connection.url = jdbc:oracle:thin:@localhost:1521:time
hibernate.connection.username = helloworld
hibernate.connection.password = hello
hibernate.default_schema = helloworld


Hibernate version:
3.2.4.sp1, May 18, 2007

Hibernate tools version:
org.hibernate.eclipse
3.2.0.beta8

Oracle version:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit on Windose 2003 SP2, x64 Edition

here's the ant log:
Code:
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.5 in: c:\Program Files\Java\jdk1.5.0_12\jre
Detected OS: Windows 2003
parsing buildfile c:\workspace3\helloworld-reverse\build.xml with URI = file:/c:/workspace3/helloworld-reverse/build.xml
Project base dir set to: c:\workspace3\helloworld-reverse
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
Build sequence for target(s) `reveng.hbmxml' is [reveng.hbmxml]
Complete build sequence is [reveng.hbmxml, reveng.entities, reveng.pojos, clean, dbmanager, ]

reveng.hbmxml:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.0.cr5
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.cfg.reveng.OverrideRepository addFile
[hibernatetool] INFO: Override file: c:\workspace3\helloworld-reverse\helloworld.reveng.xml
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: Hibernate connection pool size: 20
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: autocommit mode: false
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:time
[hibernatetool] Jul 2, 2007 2:46:52 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: connection properties: {user=helloworld, password=****}
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
[hibernatetool] With the Partitioning, OLAP and Data Mining options
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: JDBC driver: Oracle JDBC driver, version: 10.2.0.3.0
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.dialect.Dialect <init>
[hibernatetool] INFO: Using dialect: org.hibernate.dialect.OracleDialect
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
[hibernatetool] INFO: Using default transaction strategy (direct JDBC transactions)
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
[hibernatetool] INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Automatic flush during beforeCompletion(): disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Automatic session close at end of transaction: disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: JDBC batch size: 15
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: JDBC batch updates for versioned data: disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Scrollable result sets: enabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: JDBC3 getGeneratedKeys(): disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Connection release mode: auto
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Default schema: helloworld
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Default batch fetch size: 1
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Generate SQL with comments: disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Order SQL updates by primary key: disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
[hibernatetool] INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
[hibernatetool] INFO: Using ASTQueryTranslatorFactory
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Query language substitutions: {}
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: JPA-QL strict compliance: disabled
[hibernatetool] Jul 2, 2007 2:46:53 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Second-level cache: enabled
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Query cache: disabled
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory createCacheProvider
[hibernatetool] INFO: Cache provider: org.hibernate.cache.NoCacheProvider
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Optimize cache for minimal puts: disabled
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Structured second-level cache entries: disabled
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Statistics: disabled
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Deleted entity synthetic identifier rollback: disabled
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.cfg.SettingsFactory buildSettings
[hibernatetool] INFO: Default entity-mode: pojo
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.connection.DriverManagerConnectionProvider close
[hibernatetool] INFO: cleaning up connection pool: jdbc:oracle:thin:@localhost:1521:time
[hibernatetool] Jul 2, 2007 2:46:54 PM org.hibernate.tool.Version <clinit>
[hibernatetool] INFO: Hibernate Tools 3.2.0.beta8
[hibernatetool] 2. task: cfg2cfgxml (Generates hibernate.cfg.xml)

BUILD SUCCESSFUL
Total time: 2 seconds



Thanks for your help

----
I also put the build.xml here. All reveng tartgets works fine with HSQLDB but generates nothing when the db.properties file is replaced with the Oracle properties:
Code:
<project name="Hello World Reverse" default="compile" basedir=".">

    <!-- Name of project and version -->
    <property name="proj.name"      value="Hello World Reverse"/>
    <property name="proj.shortname" value="helloworld-reverse"/>
    <property name="version"        value="1.0"/>

    <!-- Global properties for this build -->
    <property name="database.dir"           value="database"/>
    <property name="src.java.dir"           value="src/java"/>
    <property name="lib.dir"                value="lib"/>

    <!-- Classpath declaration -->
    <path id="project.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
            <include name="**/*.zip"/>
        </fileset>
    </path>

    <!-- Useful shortcuts -->
    <patternset id="meta.files">
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>
    </patternset>

    <!-- Clean up -->
    <target name="clean" description="Clean the source directory">
        <delete dir="${src.java.dir}"/>
        <mkdir dir="${src.java.dir}"/>
    </target>

    <!-- Start the HSQL DB browser tool -->
    <target name="dbmanager" description="Start HSQL DB manager">
        <java
            classname="org.hsqldb.util.DatabaseManagerSwing"
            fork="yes"
            classpathref="project.classpath"
            failonerror="true">
            <arg value="-url"/>
            <arg value="jdbc:hsqldb:hsql://localhost/"/>
            <arg value="-driver"/>
            <arg value="org.hsqldb.jdbcDriver"/>
        </java>
    </target>

    <!-- Enable the HibernateToolTask -->
    <taskdef name="hibernatetool"
             classname="org.hibernate.tool.ant.HibernateToolTask"
             classpathref="project.classpath"/>

    <!-- Generate XML metadata mappig files from database schema -->
    <target name="reveng.hbmxml"
            description="Read database, generate XML mapping files">

        <hibernatetool destdir="${src.java.dir}">
            <jdbcconfiguration
                propertyfile="${basedir}/helloworld.db.properties"
                revengfile="${basedir}/helloworld.reveng.xml"/>
            <hbm2hbmxml/>
            <hbm2cfgxml/>
        </hibernatetool>

    </target>

    <!-- Generate Java persistent classes from XML mapping files -->
    <target name="reveng.pojos"
            description="Read XML mapping files, generate POJOs">

        <hibernatetool destdir="${src.java.dir}">
            <configuration>
                <fileset dir="${src.java.dir}">
                    <include name="**/*.hbm.xml"/>
                </fileset>
            </configuration>
            <hbm2java/> <!-- Generate POJO source -->
        </hibernatetool>

    </target>

    <!-- Generate annotated Java entity beans from database schema -->
    <target name="reveng.entities"
            description="Read database, generate Java entity beans">

        <hibernatetool destdir="${src.java.dir}">
            <jdbcconfiguration
                propertyfile="${basedir}/helloworld.db.properties"
                revengfile="${basedir}/helloworld.reveng.xml"/>
            <hbm2java jdk5="true" ejb3="true"/>
            <hbm2cfgxml ejb3="true"/>
        </hibernatetool>

    </target>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 11:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
oracle is case sensitive about its schema name. Use HELLOWORLD

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Thanks, this helped
PostPosted: Mon Jul 02, 2007 12:11 pm 
Newbie

Joined: Fri Jun 29, 2007 5:59 am
Posts: 4
Thanks for your help, capitalizing the schemaname has finally made the reveng work against Oracle DB.

Please correct me, but I guess it's not the Oracle what is case-sensitive, but the reveng tool. Core Hibernate persistence features worked fine with Oracle DB and with lowercase schemaname (in chg.xml or db.properties).

Thanks Again,
Gergo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 2:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well, no it is oracle that is case sensitive when asked what tables it has in a schema.

"select * from someschema.yourtable" works, but jdbcmetadata.getTables(null, "someschema", "%") will return nothing.

here you need to put "SOMESCHEMA" - so it is oracle that is casesensitive.

note, in svn (and i think/thought b9) I try to ask the metadata if it is casesensitive and what casing it uses and then adjust the query accordingly....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 2:57 pm 
Newbie

Joined: Fri Jun 29, 2007 5:59 am
Posts: 4
OK,
thanks for unfolding this.

Gergo


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