-->
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.  [ 3 posts ] 
Author Message
 Post subject: hbm2ddl not generating schema, but output says it is
PostPosted: Sun May 28, 2006 4:29 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
Here's an excerpt of my Ant output that executes without error against HSQLDB according to the output...unfortunately, there's no actual update against the DB (even though export="true"), and I can't figure out why!?!?

When the hbm2ddl task completes, in my [i]data[/i] folder there's the DDL file, and 3 other files for my testdb database:
- testdb.lck
- testdb.log
- testdb.properties

What's interesting is that testdb.log only has one statement in it, and it's the following:
CREATE USER SA PASSWORD "" ADMIN

Shouldn't I be seeing the DDL statements in there too?

I've also included below the hibernate.cfg.xml, the single mapping file, and hbm2ddl task...the DDL statements can be seen in the Ant output. Please help...I've really hit a wall here...

Thanks.



[b]Excerpt of Ant output:[/b]
[code][hibernatetool] 14:11:08,531 INFO SchemaExport:152 - Running hbm2ddl schema export
[hibernatetool] 14:11:08,546 DEBUG SchemaExport:168 - import file not found: /import.sql
[hibernatetool] 14:11:08,562 INFO SchemaExport:172 - writing generated schema to file: C:\Documents and Settings\Admin\My Documents\Workspace\Test\data\createdb.ddl
[hibernatetool] 14:11:08,562 INFO SchemaExport:177 - exporting generated schema to database
[hibernatetool] 14:11:08,578 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] 14:11:08,578 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
[hibernatetool] 14:11:08,578 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[hibernatetool] 14:11:08,578 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:C:/Documents and Settings/Admin/My Documents/Workspace/Test/data/testdb
[hibernatetool] 14:11:08,578 INFO DriverManagerConnectionProvider:83 - connection properties: {user=sa, password=}
[hibernatetool] 14:11:08,578 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
[hibernatetool] 14:11:08,578 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
[hibernatetool] 14:11:09,062 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:hsqldb:file:C:/Documents and Settings/Admin/My Documents/Workspace/Test/data/testdb, Isolation Level: 2
[hibernatetool] drop table Pet if exists;
[hibernatetool] 14:11:09,078 DEBUG SchemaExport:301 -
[hibernatetool] drop table Pet if exists;
[hibernatetool] drop table hibernate_unique_key if exists;
[hibernatetool] 14:11:09,078 DEBUG SchemaExport:301 -
[hibernatetool] drop table hibernate_unique_key if exists;
[hibernatetool] create table Pet (
[hibernatetool] ID integer not null,
[hibernatetool] name varchar(255),
[hibernatetool] primary key (ID)
[hibernatetool] );
[hibernatetool] 14:11:09,093 DEBUG SchemaExport:301 -
[hibernatetool] create table Pet (
[hibernatetool] ID integer not null,
[hibernatetool] name varchar(255),
[hibernatetool] primary key (ID)
[hibernatetool] );
[hibernatetool] create table hibernate_unique_key (
[hibernatetool] next_hi integer
[hibernatetool] );
[hibernatetool] 14:11:09,093 DEBUG SchemaExport:301 -
[hibernatetool] create table hibernate_unique_key (
[hibernatetool] next_hi integer
[hibernatetool] );
[hibernatetool] insert into hibernate_unique_key values ( 0 );
[hibernatetool] 14:11:09,093 DEBUG SchemaExport:301 -
[hibernatetool] insert into hibernate_unique_key values ( 0 );
[hibernatetool] 14:11:09,125 INFO SchemaExport:194 - schema export complete
[hibernatetool] 14:11:09,125 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
[hibernatetool] 14:11:09,125 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:file:C:/Documents and Settings/Admin/My Documents/Workspace/Test/data/testdb
BUILD SUCCESSFUL
Total time: 5 seconds[/code]

[b]Ant target:[/b]
[code] <target name="schemaexport" depends="preparecompile">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" />
<hibernatetool destdir="data">
<configuration configurationfile="src/hibernate.cfg.xml" />
<hbm2ddl export="true" update="false" drop="false" create="false" delimiter=";" outputfilename="createdb.ddl" format="true" />
</hibernatetool>
</target>[/code]

[b]hibernate.cfg.xml:[/b]
[code]<?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">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:file:C:/Documents and Settings/Admin/My Documents/Workspace/Test/data/testdb</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="top/Pet.hbm.xml"/>
</session-factory>
</hibernate-configuration>[/code]

[b]Only mapping file:[/b]
[code]<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="top">
<class name="Pet">
<id name="id" column="ID" type="int">
<generator class="hilo">
</generator>
</id>
<property name="name" type="java.lang.String"/>
</class>
</hibernate-mapping>[/code][/i][/i]


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 8:16 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
I tried to leave out outputfilename="createdb.ddl" from the <hbm2ddl> tag, in hopes that if there's no output file, all DDL statements would be executed only in the database and not outputted to a file.

However, in this case I get a NullPointerException at Ant build time...apparently the outputfilename attribute isn't "optional"!

But I imagine if I could leave out outputfilename, the problem wouldn't be solved...the Ant output seems to show that everything worked fine, as in the following line:

[hibernatetool] 14:11:09,125 INFO SchemaExport:194 - schema export complete

Would you guess that this is this an issue with my configuration of HSQLDB, or my configuration of Hibernate, or something else? Any advice on how to proceed would be greatly appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 3:41 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
i noticed to have the same problem.
When i generate the database with SchemaExport the tool don't works!
The only way is to using:
<property name="hbm2ddl.auto">create</property>
in hibernate configuration file


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