-->
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.  [ 10 posts ] 
Author Message
 Post subject: Empty Schema Generation
PostPosted: Fri Sep 09, 2005 1:48 pm 
Newbie

Joined: Fri Sep 09, 2005 1:10 pm
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 3:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and what is the problem ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: RE:Empty Schema Generation
PostPosted: Fri Sep 09, 2005 3:40 pm 
Newbie

Joined: Fri Sep 09, 2005 1:10 pm
Posts: 5
Max,

The target Schema file is empty (no content).

Dave

_________________
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 4:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so C:\eclipse\workspace\electronic-transactions\db\schema.ddl is empty...and what if you dont do it to a file but just to the console ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 4:49 pm 
Newbie

Joined: Fri Sep 09, 2005 1:10 pm
Posts: 5
Nothing appears in the console when I adjust the console="true"

<hbm2ddl create="yes" console="true" outputFileName="schema.ddl" delimiter=","/>

_________________
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 11, 2005 11:22 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Place the following in hibernate.cfg.xml .

Code:
        <mapping resource="Mapping1" />
        <mapping resource="Mapping2" />


Top
 Profile  
 
 Post subject: Re Empty Schema Generation
PostPosted: Mon Sep 12, 2005 11:44 am 
Newbie

Joined: Fri Sep 09, 2005 1:10 pm
Posts: 5
As soon as I enter the mapping resource I get the following:

org.hibernate.MappingException: Resource: data/objects/ElectronicTransactions.hbm.xml not found

which is the first <mapping resource=""/> entry. I've tried
changing the path from "ElectronicTransactions.hbm.xml", but it does not
find the resource. I'm not sure where to set the classpath in the config
file so that it will find these resources?

_________________
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 12:16 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Keep experimenting w/ the paths. Try the following:

a relative path to hibernate.cfg.xml
a relative path to ant's @basedir for the project element of the ant script.
an absolute path


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 5:27 pm 
Newbie

Joined: Fri Sep 09, 2005 1:10 pm
Posts: 5
Thanks Dennis. I finally got it working. I think I would recommend building the entire ant script outside of eclipse though.

_________________
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 5:46 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Don't forget to rate ;-)


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