-->
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.  [ 1 post ] 
Author Message
 Post subject: hbm2ddl ant task
PostPosted: Thu Feb 16, 2012 1:56 pm 
Newbie

Joined: Thu Feb 16, 2012 1:34 pm
Posts: 1
Hello,

I'm taking my first steps in Hibernate annotations. All was going well, until I configured my ant build file to generate the actual database. It created the right statements (they work in sql developer), but for some reason the hbm2ddl task cannot create the tables. The oracle message is as general as can be, so no luck there either...

This is the output of my ant script :

Code:
D:\Development\Java\Projects\annotations>ant exportDDL
Buildfile: D:\Development\Java\Projects\annotations\build.xml

compile:
    [javac] D:\Development\Java\Projects\annotations\build.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to
epeatable builds
    [javac] Compiling 1 source file to D:\Development\Java\Projects\annotations\bin

exportDDL:
   [htools] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
   [htools] 1. task: hbm2ddl (Generates database schema)
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.annotations.common.Version <clinit>
   [htools] INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.Version logVersion
   [htools] INFO: HHH000412: Hibernate Core {4.0.1.Final}
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.cfg.Environment <clinit>
   [htools] INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.username=danny, hibernate.connection.password=****
.dialect=org.hibernate.dialect.Oracle10gDialect, hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:XE, hibernate.bytecode.use_reflection_optimizer=
rnate.connection.driver_class=oracle.jdbc.driver.OracleDriver}
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.cfg.Environment buildBytecodeProvider
   [htools] INFO: HHH000021: Bytecode provider name : javassist
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.cfg.Configuration configure
   [htools] INFO: HHH000042: Configuring from file: hibernate.cfg.xml
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
   [htools] WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead
Hibernate 3.6 Migration Guide!
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.cfg.Configuration doConfigure
   [htools] INFO: HHH000041: Configured SessionFactory: null
   [htools] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
   [htools] SLF4J: Defaulting to no-operation (NOP) logger implementation
   [htools] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
   [htools] INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
   [htools] INFO: HHH000115: Hibernate connection pool size: 0
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
   [htools] INFO: HHH000006: Autocommit mode: false
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
   [htools] INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:XE]
   [htools] Feb 16, 2012 6:27:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
   [htools] INFO: HHH000046: Connection properties: {user=danny, password=****}
   [htools] Feb 16, 2012 6:27:05 PM org.hibernate.dialect.Dialect <init>
   [htools] INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
   [htools] Feb 16, 2012 6:27:05 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
   [htools] INFO: HHH000227: Running hbm2ddl schema export
   [htools]
   [htools]     create table ALBUMS (
   [htools]         id number(19,0) not null,
   [htools]         creationDate timestamp,
   [htools]         public_access number(1,0),
   [htools]         summary blob,
   [htools]         title varchar2(255 char),
   [htools]         xResize number(10,0) not null,
   [htools]         yResize number(10,0) not null,
   [htools]         coverPhoto_id number(19,0),
   [htools]         primary key (id)
   [htools]     );
   [htools] Feb 16, 2012 6:27:05 PM org.hibernate.tool.hbm2ddl.SchemaExport perform
   [htools] ERROR: HHH000389: Unsuccessful: create table ALBUMS (id number(19,0) not null, creationDate timestamp, public_access number(1,0), summary blob,
har2(255 char), xResize number(10,0) not null, yResize number(10,0) not null, coverPhoto_id number(19,0), primary key (id))
   [htools] Feb 16, 2012 6:27:05 PM org.hibernate.tool.hbm2ddl.SchemaExport perform
   [htools] ERROR: ORA-00911: invalid character
   [htools]
   [htools] Feb 16, 2012 6:27:05 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
   [htools] INFO: HHH000230: Schema export complete


This oracle error message is generated for the creation of all tables, so I don't think it's related to any major flaws in my annotations.'
Has anyone experienced similar problems with Oracle11g XE?


This is the mapping file
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
       <property name="hibernate.connection.pool_size">0</property>       
        <property name="show_sql">false</property>
        <property name="hbm2ddl.auto">create</property>
        <mapping class="Album"/>
        <mapping class="Photo"/>
        <mapping class="User"/>
        <mapping class="Comment"/>
        <mapping class="AlbumComment"/>
        <mapping class="PhotoComment"/>   
    </session-factory>
</hibernate-configuration>



The jars I'm using are :
ejb3-persistence
freemarker 2.3.18
hibernate annotations 3.0beta2
ojdbc6.jar
slf4j-api-1.6.4
hibernate 4.0.1

The full build.xml

Code:
<project name="annotations">
   
   <property file="build.properties"/>
   <property name="src" location="src"/>
   <property name="bin" location="bin"/>
   <property name="sql" location="sql"/>

   <path id="classpath.base">
      <pathelement path="${src}"/>
      <pathelement path="${bin}"/>
      <pathelement location="${hibernate.path}"/>
      <fileset dir="${hibernate.lib}" includes="**/*.jar"/>
        <pathelement location="${hibernate.annotations.path}"/>
      <fileset dir="${hibernate.annotations.lib}" includes="**/*.jar"/>
        <pathelement location="${jdbc.driver.path}"/>
   </path>

   <path id="classpath.tools">
      <path refid="classpath.base"/>
      <pathelement location="${hibernate.tools.path}"/>
   </path>

   <taskdef
          name="htools"
          classname="org.hibernate.tool.ant.HibernateToolTask"
          classpathref="classpath.tools"/>

   <target name="exportDDL" depends="compile">
        <mkdir dir="${sql}"/>
      <htools destdir="${sql}">
         <classpath refid="classpath.tools"/>
         <annotationconfiguration configurationfile="${src}/hibernate.cfg.xml"/>
         <hbm2ddl create="true" format="true" export="true" outputfilename="${ant.project.name}.dll"/>
      </htools>
   </target>

   <target name="compile">
        <mkdir dir="bin"/>
      <javac srcdir="${src}" destdir="${bin}" classpathref="classpath.base"/>
   </target>
</project>


with properties file :
Code:
servlet.path=D:/Development/Java/Projects/annotations/lib/servlet-api.jar
jdbc.driver.path=D:/Development/Java/Projects/annotations/lib/ojdbc6.jar
hibernate.lib=D:/Development/Java/Jars/hibernate 4/hibernate-4.0.1/lib/required
hibernate.path=D:/Development/Java/Jars/hibernate 4/hibernate-4.0.1/lib/required/hibernate-core-4.0.1.Final.jar
hibernate.tools.path=D:/Development/Java/Eclipse/plugins/org.jboss.tools.hibernateextension4_0_3.4.0.v20111213-1944-H40-M5/lib/tools/hibernate-tools-3.5.0.Beta.jar
hibernate.annotations.lib=D:/Development/Java/Projects/annotations/lib
hibernate.annotations.path=D:/Development/Java/Projects/annotations/lib/hibernate-annotations-3.0beta2.jar


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.