Cheers and thanks for what ever help.
This is my problem in a nutshell. I built an "Ant" build.xml file
to execute "org.hibernate.tool.hbm2ddl.SchemaExportTask"
via a target/task. The task works great when I create "SQL" scripts; but
when I change the "text" attribute to equal "no" the "Ant" task
fails to export the schema.
Note: This tid-bit seems a bit wierd to me; but, when I failed at exporting to the database,
via mentioned "Ant" task; I created a quick and dirty application. The application was
built around "org.hibernate.tool.hbm2ddl.SchemaExport" and successfully
exported the schema. This proved to me that the Oracle "JDBC" driver was good, "Hibernate 3.1" was good, and j2sdk1.4.2_07 was good.
I am using the following:
"Ant" (1.6.2)
"Hibernate" (3.1)
"Java" (j2sdk1.4.2_07)
"Oracle" (10g)
Please see the mapping file (dummy.hbm.xml) near bottom
of this and build.xml too.
BELOW IS THE SUCCESSFUL CONSOLE OUTPUT I GET WHEN I RUN
org.hibernate.tool.hbm2ddl.SchemaExportTask
VIA THIS ANT TASK WITH THE FOLLOWING SETTINGS,
<schemaexport
properties="${class.root}/hibernate.properties"
quiet="no"
text="yes"
drop="no"
delimiter=";"
output="create_oracle_9-10g.sql">
<fileset dir="${class.root}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
, NO PROBLEMS EVERYTHING WORKS AS EXPECTED... SCRIPT
GETS CREATED INTO A FILE NAMED "create_oracle_9-10g.sql":
C:\eclipse3.0\eclipse\workspace\Spring_Hibernate>ant -verbose schema
Apache Ant version 1.6.2 compiled on July 16 2004
Buildfile: build.xml
Detected Java version: 1.4 in: C:\j2sdk1.4.2_07\jre
Detected OS: Windows XP
parsing buildfile C:\eclipse3.0\eclipse\workspace\Spring_Hibernate\build.xml with URI = file:///C:/eclipse3.0/eclipse/workspace/Spring_Hibernate/build.xml
Project base dir set to: C:\eclipse3.0\eclipse\workspace\Spring_Hibernate
Build sequence for target `schema' is [schema]
Complete build sequence is [schema, prepare, compile, ]
schema:
[schemaexport] 2006-01-27 07:50:53,065 INFO [org.hibernate.cfg.Environment] - Hi
bernate 3.1.1
[schemaexport] 2006-01-27 07:50:53,085 INFO [org.hibernate.cfg.Environment] - lo
aded properties from resource hibernate.properties: {hibernate.connection.driver
_class=oracle.jdbc.OracleDriver, hibernate.connection.name=eims, hibernate.cglib
.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cac
he.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hi
bernate.dialect.Oracle9Dialect, hibernate.jdbc.use_streams_for_binary=true, hibe
rnate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.
proxool.pool_alias=pool1, hibernate.cache.region_prefix=hibernate.test, hibernat
e.connection.url=jdbc:oracle:thin:@dev-cha-100.ne.nos.boeing.com:1521:eimsdev, h
ibernate.show_sql=true, hibernate.connection.password=****, hibernate.jdbc.batch
_versioned_data=true, hibernate.connection.pool_size=1}
[schemaexport] 2006-01-27 07:50:53,105 INFO [org.hibernate.cfg.Environment] - us
ing java.io streams to persist binary types
[schemaexport] 2006-01-27 07:50:53,105 INFO [org.hibernate.cfg.Environment] - us
ing CGLIB reflection optimizer
[schemaexport] 2006-01-27 07:50:53,105 INFO [org.hibernate.cfg.Environment] - us
ing JDK 1.4 java.sql.Timestamp handling
[schemaexport] 2006-01-27 07:50:53,606 INFO [org.hibernate.cfg.Configuration] -
Reading mappings from file: C:\eclipse3.0\eclipse\workspace\Spring_Hibernate\cla
sses\dao\dummy.hbm.xml
[schemaexport] 2006-01-27 07:50:53,836 DEBUG [org.hibernate.util.DTDEntityResolv
er] - trying to locate
http://hibernate.sourceforge.net/hibern ... ing-3.0.dt
d in classpath under org/hibernate/
[schemaexport] 2006-01-27 07:50:53,836 DEBUG [org.hibernate.util.DTDEntityResolv
er] - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classp
ath
[schemaexport] 2006-01-27 07:50:54,427 INFO [org.hibernate.cfg.HbmBinder] - Mapp
ing class: dao.Dummy -> DUMMY
[schemaexport] 2006-01-27 07:50:54,477 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: id -> ID
[schemaexport] 2006-01-27 07:50:54,618 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: fullName -> FULLNAME
[schemaexport] 2006-01-27 07:50:54,628 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: address -> address
[schemaexport] 2006-01-27 07:50:54,628 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: city -> city
[schemaexport] 2006-01-27 07:50:54,628 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: state -> state
[schemaexport] 2006-01-27 07:50:54,638 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: zip -> zip
[schemaexport] 2006-01-27 07:50:54,768 INFO [org.hibernate.dialect.Dialect] - Us
ing dialect: org.hibernate.dialect.Oracle9Dialect
[schemaexport] 2006-01-27 07:50:55,058 DEBUG [org.hibernate.cfg.Configuration] -
processing extends queue
[schemaexport] 2006-01-27 07:50:55,058 DEBUG [org.hibernate.cfg.Configuration] -
processing collection mappings
[schemaexport] 2006-01-27 07:50:55,058 DEBUG [org.hibernate.cfg.Configuration] -
processing native query and ResultSetMapping mappings
[schemaexport] 2006-01-27 07:50:55,058 DEBUG [org.hibernate.cfg.Configuration] -
processing association property references
[schemaexport] 2006-01-27 07:50:55,058 DEBUG [org.hibernate.cfg.Configuration] -
processing foreign key constraints
[schemaexport] 2006-01-27 07:50:55,359 DEBUG [org.hibernate.cfg.Configuration] -
processing extends queue
[schemaexport] 2006-01-27 07:50:55,359 DEBUG [org.hibernate.cfg.Configuration] -
processing collection mappings
[schemaexport] 2006-01-27 07:50:55,359 DEBUG [org.hibernate.cfg.Configuration] -
processing native query and ResultSetMapping mappings
[schemaexport] 2006-01-27 07:50:55,359 DEBUG [org.hibernate.cfg.Configuration] -
processing association property references
[schemaexport] 2006-01-27 07:50:55,359 DEBUG [org.hibernate.cfg.Configuration] -
processing foreign key constraints
[schemaexport] 2006-01-27 07:50:55,379 INFO [org.hibernate.tool.hbm2ddl.SchemaEx
port] - Running hbm2ddl schema export
[schemaexport] 2006-01-27 07:50:55,389 DEBUG [org.hibernate.tool.hbm2ddl.SchemaE
xport] - import file not found: /import.sql
[schemaexport] 2006-01-27 07:50:55,399 INFO [org.hibernate.tool.hbm2ddl.SchemaEx
port] - writing generated schema to file: C:\eclipse3.0\eclipse\workspace\Spring
_Hibernate\create_oracle_9-10g.sql
[schemaexport]
[schemaexport] drop table DUMMY cascade constraints;
[schemaexport] 2006-01-27 07:50:55,409 DEBUG [org.hibernate.tool.hbm2ddl.SchemaE
xport] -
[schemaexport] drop table DUMMY cascade constraints;
[schemaexport]
[schemaexport] drop sequence hibernate_sequence;
[schemaexport] 2006-01-27 07:50:55,409 DEBUG [org.hibernate.tool.hbm2ddl.SchemaE
xport] -
[schemaexport] drop sequence hibernate_sequence;
[schemaexport]
[schemaexport] create table DUMMY (
[schemaexport] ID number(10,0) not null,
[schemaexport] FULLNAME varchar2(32 char) not null,
[schemaexport] address varchar2(255 char),
[schemaexport] city varchar2(255 char),
[schemaexport] state varchar2(255 char),
[schemaexport] zip varchar2(255 char),
[schemaexport] primary key (ID)
[schemaexport] );
[schemaexport] 2006-01-27 07:50:55,459 DEBUG [org.hibernate.tool.hbm2ddl.SchemaE
xport] -
[schemaexport] create table DUMMY (
[schemaexport] ID number(10,0) not null,
[schemaexport] FULLNAME varchar2(32 char) not null,
[schemaexport] address varchar2(255 char),
[schemaexport] city varchar2(255 char),
[schemaexport] state varchar2(255 char),
[schemaexport] zip varchar2(255 char),
[schemaexport] primary key (ID)
[schemaexport] );
[schemaexport]
[schemaexport] create sequence hibernate_sequence;
[schemaexport] 2006-01-27 07:50:55,509 DEBUG [org.hibernate.tool.hbm2ddl.SchemaE
xport] -
[schemaexport] create sequence hibernate_sequence;
[schemaexport] 2006-01-27 07:50:55,509 INFO [org.hibernate.tool.hbm2ddl.SchemaEx
port] - schema export complete
BUILD SUCCESSFUL
Total time: 5 seconds
C:\eclipse3.0\eclipse\workspace\Spring_Hibernate>
BELOW IS THE UNSUCCESSFUL CONSOLE OUTPUT I GET WHEN I RUN
org.hibernate.tool.hbm2ddl.SchemaExportTask
VIA THIS ANT TASK WITH THE FOLLOWING SETTINGS, NOTICE
TEXT ATTRIBUTE IS SET TO "NO"!!!!,
<schemaexport
properties="${class.root}/hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="create_oracle_9-10g.sql">
<fileset dir="${class.root}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
. THE PROBLEM SEEMS TO BE RELATED TO THE FACT THAT
SCRIPT FILE NAMED "create_oracle_9-10g.sql" IS NEVER
INITIALIZED CORRECTLY. AFTER THE TASK HAS EXECUTED,
I OPEN UP "create_oracle_9-10g.sql" AND FIND IT TO BE BLANK
OR TEXT HAS NOT BEEN WRITTEN TO THE FILE:
C:\eclipse3.0\eclipse\workspace\Spring_Hibernate>ant -verbose schema
Apache Ant version 1.6.2 compiled on July 16 2004
Buildfile: build.xml
Detected Java version: 1.4 in: C:\j2sdk1.4.2_07\jre
Detected OS: Windows XP
parsing buildfile C:\eclipse3.0\eclipse\workspace\Spring_Hibernate\build.xml wit
h URI = file:///C:/eclipse3.0/eclipse/workspace/Spring_Hibernate/build.xml
Project base dir set to: C:\eclipse3.0\eclipse\workspace\Spring_Hibernate
Build sequence for target `schema' is [schema]
Complete build sequence is [schema, prepare, compile, ]
schema:
[schemaexport] 2006-01-27 08:02:20,377 INFO [org.hibernate.cfg.Environment] - Hi
bernate 3.1.1
[schemaexport] 2006-01-27 08:02:20,397 INFO [org.hibernate.cfg.Environment] - lo
aded properties from resource hibernate.properties: {hibernate.connection.driver
_class=oracle.jdbc.OracleDriver, hibernate.connection.name=eims, hibernate.cglib
.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cac
he.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hi
bernate.dialect.Oracle9Dialect, hibernate.jdbc.use_streams_for_binary=true, hibe
rnate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.
proxool.pool_alias=pool1, hibernate.cache.region_prefix=hibernate.test, hibernat
e.connection.url=jdbc:oracle:thin:@dev-cha-100.ne.nos.boeing.com:1521:eimsdev, h
ibernate.show_sql=true, hibernate.connection.password=****, hibernate.jdbc.batch
_versioned_data=true, hibernate.connection.pool_size=1}
[schemaexport] 2006-01-27 08:02:20,417 INFO [org.hibernate.cfg.Environment] - us
ing java.io streams to persist binary types
[schemaexport] 2006-01-27 08:02:20,417 INFO [org.hibernate.cfg.Environment] - us
ing CGLIB reflection optimizer
[schemaexport] 2006-01-27 08:02:20,417 INFO [org.hibernate.cfg.Environment] - us
ing JDK 1.4 java.sql.Timestamp handling
[schemaexport] 2006-01-27 08:02:20,918 INFO [org.hibernate.cfg.Configuration] -
Reading mappings from file: C:\eclipse3.0\eclipse\workspace\Spring_Hibernate\cla
sses\dao\dummy.hbm.xml
[schemaexport] 2006-01-27 08:02:21,138 DEBUG [org.hibernate.util.DTDEntityResolv
er] - trying to locate
http://hibernate.sourceforge.net/hibern ... ing-3.0.dt
d in classpath under org/hibernate/
[schemaexport] 2006-01-27 08:02:21,148 DEBUG [org.hibernate.util.DTDEntityResolv
er] - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classp
ath
[schemaexport] 2006-01-27 08:02:21,729 INFO [org.hibernate.cfg.HbmBinder] - Mapp
ing class: dao.Dummy -> DUMMY
[schemaexport] 2006-01-27 08:02:21,779 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: id -> ID
[schemaexport] 2006-01-27 08:02:21,920 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: fullName -> FULLNAME
[schemaexport] 2006-01-27 08:02:21,930 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: address -> address
[schemaexport] 2006-01-27 08:02:21,930 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: city -> city
[schemaexport] 2006-01-27 08:02:21,930 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: state -> state
[schemaexport] 2006-01-27 08:02:21,930 DEBUG [org.hibernate.cfg.HbmBinder] - Map
ped property: zip -> zip
[schemaexport] 2006-01-27 08:02:22,070 INFO [org.hibernate.dialect.Dialect] - Us
ing dialect: org.hibernate.dialect.Oracle9Dialect
[schemaexport] 2006-01-27 08:02:22,360 DEBUG [org.hibernate.cfg.Configuration] -
processing extends queue
[schemaexport] 2006-01-27 08:02:22,360 DEBUG [org.hibernate.cfg.Configuration] -
processing collection mappings
[schemaexport] 2006-01-27 08:02:22,360 DEBUG [org.hibernate.cfg.Configuration] -
processing native query and ResultSetMapping mappings
[schemaexport] 2006-01-27 08:02:22,360 DEBUG [org.hibernate.cfg.Configuration] -
processing association property references
[schemaexport] 2006-01-27 08:02:22,360 DEBUG [org.hibernate.cfg.Configuration] -
processing foreign key constraints
[schemaexport] 2006-01-27 08:02:22,661 DEBUG [org.hibernate.cfg.Configuration] -
processing extends queue
[schemaexport] 2006-01-27 08:02:22,661 DEBUG [org.hibernate.cfg.Configuration] -
processing collection mappings
[schemaexport] 2006-01-27 08:02:22,661 DEBUG [org.hibernate.cfg.Configuration] -
processing native query and ResultSetMapping mappings
[schemaexport] 2006-01-27 08:02:22,661 DEBUG [org.hibernate.cfg.Configuration] -
processing association property references
[schemaexport] 2006-01-27 08:02:22,671 DEBUG [org.hibernate.cfg.Configuration] -
processing foreign key constraints
[schemaexport] 2006-01-27 08:02:22,681 INFO [org.hibernate.tool.hbm2ddl.SchemaEx
port] - Running hbm2ddl schema export
[schemaexport] 2006-01-27 08:02:22,691 DEBUG [org.hibernate.tool.hbm2ddl.SchemaE
xport] - import file not found: /import.sql
[schemaexport] 2006-01-27 08:02:22,701 INFO [org.hibernate.tool.hbm2ddl.SchemaEx
port] - writing generated schema to file: C:\eclipse3.0\eclipse\workspace\Spring
_Hibernate\create_oracle_9-10g.sql
[schemaexport] 2006-01-27 08:02:22,701 INFO [org.hibernate.tool.hbm2ddl.SchemaEx
port] - exporting generated schema to database
[schemaexport] 2006-01-27 08:02:22,721 INFO [org.hibernate.connection.DriverMana
gerConnectionProvider] - Using Hibernate built-in connection pool (not for produ
ction use!)
[schemaexport] 2006-01-27 08:02:22,721 INFO [org.hibernate.connection.DriverMana
gerConnectionProvider] - Hibernate connection pool size: 1
[schemaexport] 2006-01-27 08:02:22,721 INFO [org.hibernate.connection.DriverMana
gerConnectionProvider] - autocommit mode: false
[schemaexport] 2006-01-27 08:02:22,771 INFO [org.hibernate.connection.DriverMana
gerConnectionProvider] - using driver: oracle.jdbc.OracleDriver at URL: jdbc:ora
cle:thin:@dev-cha-100.ne.nos.boeing.com:1521:eimsdev
[schemaexport] 2006-01-27 08:02:22,771 INFO [org.hibernate.connection.DriverMana
gerConnectionProvider] - connection properties: {name=eims, password=eims}
[schemaexport] 2006-01-27 08:02:22,771 DEBUG [org.hibernate.connection.DriverMan
agerConnectionProvider] - total checked-out connections: 0
[schemaexport] 2006-01-27 08:02:22,771 DEBUG [org.hibernate.connection.DriverMan
agerConnectionProvider] - opening new JDBC connection
[schemaexport] 2006-01-27 08:02:23,322 ERROR [org.hibernate.tool.hbm2ddl.SchemaE
xport] - schema export unsuccessful
[schemaexport] java.sql.SQLException: invalid arguments in call
[schemaexport] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseEr
ror.java:125)
[schemaexport] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseEr
ror.java:162)
[schemaexport] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseEr
ror.java:227)
[schemaexport] at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:197
)
[schemaexport] at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnecti
on.java:344)
[schemaexport] at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:14
8)
[schemaexport] at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriver
Extension.java:32)
[schemaexport] at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545
)
[schemaexport] at java.sql.DriverManager.getConnection(DriverManager.java:512)
[schemaexport] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[schemaexport] at org.hibernate.connection.DriverManagerConnectionProvider.getC
onnection(DriverManagerConnectionProvider.java:110)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHel
per.getConnection(SchemaExport.java:467)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.
java:183)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExp
ortTask.java:146)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1062
)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
BUILD SUCCESSFUL
Total time: 6 seconds
C:\eclipse3.0\eclipse\workspace\Spring_Hibernate>
THIS IS THE MAPPING FILE:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="dao.Dummy" table="DUMMY">
<id name="id" type="int" >
<column name="ID" not-null="true"/>
<generator class="native"/>
</id>
<property name="fullName">
<column name="FULLNAME" length="32" not-null="true"/>
</property>
<property name="address"/>
<property name="city"/>
<property name="state"/>
<property name="zip"/>
</class>
</hibernate-mapping>
THIS IS THE BUILD FILE:
<?xml version="1.0"?>
<project name="To the ends of the earth! Jones, full speed ahead. Arhhgg matie!"
default="compile" basedir=".">
<!-- Set up properties containing important project directories -->
<property name="source.root" value="src"/>
<property name="class.root" value="classes"/>
<property name="hibernate3-1.root.dir" value="/bogus/downloads/hibernate/hibernate-3.1" />
<property name="lib.dir" value="${hibernate3-1.root.dir}/lib"/>
<property name="oracle.driver.dir" value="/bogus/downloads/oracleJDBCDriver" />
<!-- Set up the class path for compilation and execution -->
<path id="project.class.path">
<!-- Include our own classes, of course -->
<pathelement location="${class.root}" />
<!-- Include jars in the project library directory -->
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${hibernate3-1.root.dir}">
<include name="hibernate3.jar"/>
</fileset>
<fileset dir="${oracle.driver.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Create our runtime subdirectories and copy resources into them -->
<target name="prepare" description="Sets up build structures">
<mkdir dir="${class.root}"/>
<!-- Copy our property files and O/R mappings for use at runtime -->
<copy todir="${class.root}" >
<fileset dir="${source.root}" >
<include name="**/*.properties"/>
<include name="**/*.hbm.xml"/>
</fileset>
</copy>
</target>
<!-- Compile the java source of the project -->
<target name="compile" depends="prepare"
description="Compiles all Java classes">
<javac srcdir="${source.root}"
destdir="${class.root}"
debug="on"
optimize="off"
deprecation="on">
<classpath refid="project.class.path"/>
</javac>
</target>
<!-- Generate the schemas for all mapping files in our class tree -->
<target name="schema" depends=""
description="Generate DB schema from the O/R mapping files">
<!-- Teach Ant how to use Hibernate's schema generation tool -->
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.class.path"/>
<schemaexport
properties="${class.root}/hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="create_oracle_9-10g.sql">
<fileset dir="${class.root}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
</project>