I am using Hibernate 3.1b2, tools 3.1 alpha4, ant 1.6.5 in eclipse.
This is a bit of a long post as I've attached the config, partial ant build, 2 mapping files, and the log output.
hibernate.cfg.xml:
<?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">
<!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration>
<session-factory> <property name="myeclipse.connection.profile"> microsoft sql </property> <property name="connection.url"> jdbc:microsoft:sqlserver://CESQLSERVER:1433 </property> <property name="connection.username">VLS</property> <property name="connection.password">dataserver</property> <property name="connection.driver_class"> com.microsoft.jdbc.sqlserver.SQLServerDriver </property> <property name="dialect"> org.hibernate.dialect.SQLServerDialect </property> <property name="jdbc.fetch_size">50</property> <property name="connection.pool_size">20</property>
</session-factory>
</hibernate-configuration>
From Ant Build Script:
<target name="schema-export" depends="build" description="trying to generate schema"> <!-- Defining the Task --> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpath="${compile.lib.dir}/hibernate-tools.jar; ${compile.lib.dir}/hibernate3.jar; ${compile.lib.dir}/dom4j-1.6.jar"/> <hibernatetool destDir="db"> <classpath> <!-- Class and library files --> <path location="${compile.lib.dir}/*.jar"/> <path location="${src.dir}/*.hbm.xml"/> <!-- jdbc jar files --> <path location="C:\sql2000jdbc\lib\mssqlserver.jar"/> <path location="C:\sql2000jdbc\lib\msbase.jar"/> <path location="C:\sql2000jdbc\lib\msutil.jar"/> </classpath> <!-- <annotationconfiguration configurationfile="${base.dir}/hibernate.cfg.xml"/> --> <configuration configurationfile="${src.dir}/hibernate.cfg.xml" /> <hbm2ddl create="yes" outputFileName="schema.ddl" delimiter=","/> </hibernatetool> </target>
Mapping 1:
<?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 package="electronic-transactions.data.objects"> <class name="ETransControl"> <!-- Primary Key Column --> <id name="batchId" column="Batch_ID" type="java.lang.Long"> <generator class="native"/> </id> <!-- Collections, Sets, ArrayLists, etc For Children --> <array name="eTransactions" table="ETransControl" cascade="persist"> <key column="batchId"/> <list-index column="requestId"/> <one-to-many class="ElectronicTransactions"/> </array> <!-- <list name="eTransactions" inverse="true" cascade="all"> <list-index column="batchId"/> <key column="batchId" not-null="true"/> <one-to-many class="ElectronicTransactions"/> </list> -->
<!-- Columns/Property names and values --> <property name="batchAmount" column="Batch_Amount" type="java.math.BigDecimal" precision="10" scale="2" not-null="true" update="true" /> <property name="batchDate" column="Batch_Date" type="java.util.Date" not-null="false" update="false" /> <!-- Computed Count Over ElectronicTransactions --> <property name="computedCount" column="Computed_Batch_Count" formula="SELECT COUNT(*) FROM ElectronicTransactions" type="long" not-null="true" update="true" /> <!-- Computed Sum Over ElectronicTransactions --> <property name="computedTotal" column="Computed_Batch_Total" formula="SELECT SUM(et.TransactionAmount) FROM ElectronicTransactions et WHERE et.TransactionAmount != 0" type="java.math.BigDecimal" precision="10" scale="2" not-null="true" update="true" /> <property name="importStatus" column="Import_Status" type="jva.lang.String" length="1" not-null="true" update="true" /> <!-- Computed Count Over ElectronicTransactions --> <!-- Where ElectronicTransactions.validatedFlag = "Y" --> <property name="correctedTransCount" column="Transaction_Corrected_Count" formula="SELECT count(*) FROM ElectronicTransactions et WHERE et.ValidatedFlag = 'Y' " type="long" not-null="true" update="true" /> <property name="transCount" column="Transaction_Count" type="long" not-null="true" update="true" /> </class> </hibernate-mapping>
Mapping 2:
<?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 package="electronic-transactions.data.objects"> <class name="ElectronicTransactions"> <!-- Primary Key ID --> <composite-id> <key-property name="requestId" column="Request_ID" type="java.lang.String"/> <key-property name="batchId" column="Batch_ID" type="java.lang.Long"/> </composite-id> <!-- joins with parent tables --> <!-- parent ETransControl --> <many-to-one name="etransControl" class="ETransControl" column="batchId" not-null="true" cascade="save-update" /> <!-- Other columns --> <property name="accountType" column="Account_Type" type="java.lang.String" length="3" update="true" not-null="true" /> <property name="appealNumber" column="Original_Appeal_Number" type="java.lang.String" length="20" update="false" not-null="true" /> <property name="appealDept" column="Appeal_Department" type="java.lang.Long" update="true" not-null="true" /> <property name="appealMonth" column="Appeal_Month" type="java.lang.Long" update="true" not-null="true" /> <property name="appealType" column="Appeal_Type" type="java.lang.Long" update="true" not-null="true" /> <property name="appealYear" column="Appeal_Year" type="java.lang.Long" update="true" not-null="true" /> <property name="donorNumber" column="Donor_Number" type="java.lang.Long" unique="true" update="true" not-null="false" /> <property name="emailAddress" column="Email_Address" type="java.lang.String" length="50" update="true" not-null="false" /> <property name="firstName" column="First_Name" type="java.lang.String" length="30" update="true" not-null="false" /> <property name="firstTransaction" column="First_Transaction" type="java.lang.String" length="1" update="true" not-null="true" /> <property name="lastName" column="Last_Name" type="java.lang.String" length="30" update="true" not-null="false" /> <property name="originalDate" column="Original_Date" type="java.util.Date" update="true" not-null="false" /> <property name="origTransAmount" column="Original_Transaction_Amount" type="java.math.BigDecimal" precision="10" scale="2" update="true" not-null="false" /> <property name="overrideAppeal" column="Override_Appeal_Number" type="java.lang.String" length="20" update="true" not-null="false" /> <property name="paymentFrequency" column="Payment_Frequency" type="java.lang.Long" update="true" not-null="true" /> <property name="paymentType" column="Payment_Type" type="java.lang.String" length="3" update="true" not-null="false" />
<property name="processDate" column="Process_Date" type="java.util.Date" update="true" not-null="false" /> <property name="processFlag" column="Process_Flag" type="java.lang.String" length="1" update="true" not-null="false" /> <property name="totalAmount" column="Total_Amount" type="java.math.BigDecimal" precision="10" scale="2" update="true" not-null="true" /> <property name="transAmount" column="Transaction_Amount" type="java.math.BigDecimal" precision="10" scale="2" update="true" not-null="true" /> <property name="transCount" column="Transaction_Count" type="java.lang.Long" update="true" not-null="true" /> <property name="transDate" column="Transaction_Date" type="java.util.Date" update="true" not-null="false" /> <property name="validatedFlag" column="Validated_Flag" type="java.lang.String" length="1" update="true" not-null="false" /> </class> </hibernate-mapping>
Log File:
init:
compile:
build:
schema-export:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.1alpha1
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using CGLIB reflection optimizer
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: null
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing extends queue
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing collection mappings
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing association property references
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing foreign key constraints
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.dialect.Dialect <init>
[hibernatetool] INFO: Using dialect: org.hibernate.dialect.SQLServerDialect
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing extends queue
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing collection mappings
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing association property references
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing foreign key constraints
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing extends queue
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing collection mappings
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing association property references
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing foreign key constraints
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: Running hbm2ddl schema export
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: writing generated schema to file: C:\eclipse\workspace\electronic-transactions\db\schema.ddl
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: exporting generated schema to database
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: Hibernate connection pool size: 20
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: autocommit mode: false
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://CESQLSERVER:1433
[hibernatetool] Sep 9, 2005 12:17:41 PM org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: connection properties: {user=VLS, password=****}
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: schema export complete
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: SQL Warning: 0, SQLState:
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to dms
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: SQL Warning: 0, SQLState:
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed database context to 'dms'.
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: SQL Warning: 0, SQLState:
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: [Microsoft][SQLServer 2000 Driver for JDBC]Language changed to us_english
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: SQL Warning: 0, SQLState:
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.util.JDBCExceptionReporter logWarnings
[hibernatetool] WARNING: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed language setting to us_english.
[hibernatetool] Sep 9, 2005 12:17:42 PM org.hibernate.connection.DriverManagerConnectionProvider close
[hibernatetool] INFO: cleaning up connection pool: jdbc:microsoft:sqlserver://CESQLSERVER:1433
init:
dtd:
Sep 9, 2005 12:17:42 PM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:microsoft:sqlserver://CESQLSERVER:1433
BUILD SUCCESSFUL
Total time: 2 seconds
_________________ Dave
|