zI am trying to run hibernate to generate sql, populate my db and then run
some tests.
Well, if I use MySql, I do not have any issues at all. But when I switch to
hsql, i can't get the databasse tables to be created, then I get a table not
exist error in dbunit.
Here is my hibernate plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>src/main/resources</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<configurationfile>/src/main/resources/hibernate.cfg.xml</configurationfile>
<jdk5>true</jdk5>
<skip>${maven.test.skip}</skip>
</componentProperties>
</configuration>
<executions>
<execution>
<id>hbm2ddl</id>
<phase>process-test-resources</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>
</plugin>
So what am I missing? Why do the tables for Mysql but with HSQL they do not?
Also, I do not see any files generated in src/main/resources/
Here is the trace when I run hibernate alone:
[myproject] INFO [main] SchemaExport.execute(154) | Running hbm2ddl schema
export
[myproject] DEBUG [main] SchemaExport.execute(170) | import file not found:
/import.sql
[myproject] INFO [main] SchemaExport.execute(179) | exporting generated
schema to database
[myproject] INFO [main] DriverManagerConnectionProvider.configure(41) |
Using Hibernate built-in connection pool (not for production use!)
[myproject] INFO [main] DriverManagerConnectionProvider.configure(42) |
Hibernate connection pool size: 20
[myproject] INFO [main] DriverManagerConnectionProvider.configure(45) |
autocommit mode: false
[myproject] INFO [main] DriverManagerConnectionProvider.configure(80) |
using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:target/testd
b-hsql;shutdown=true
[myproject] INFO [main] DriverManagerConnectionProvider.configure(83) |
connection properties: {user=sa, password=}
[myproject] DEBUG [main] DriverManagerConnectionProvider.getConnection(93) |
total checked-out connections: 0
[myproject] DEBUG [main] DriverManagerConnectionProvider.getConnection(109)
| opening new JDBC connection
[myproject] DEBUG [main] DriverManagerConnectionProvider.getConnection(115)
| created connection to: jdbc:hsqldb:file:target/testdb-hsql;shutdown
=true, Isolation Level: 2
alter table app_user drop constraint FK459C57294AD68248;
[myproject] DEBUG [main] SchemaExport.execute(303) | alter table app_user
drop constraint FK459C57294AD68248;
[myproject] DEBUG [main] SchemaExport.drop(288) | Unsuccessful: alter table
app_user drop constraint FK459C57294AD68248
[myproject] DEBUG [main] SchemaExport.drop(289) | Table not found: APP_USER
in statement [alter table app_user]
alter table user_role drop constraint FK143BF46AE8EA6EF6;
[myproject] DEBUG [main] SchemaExport.execute(303) | alter table user_role
drop constraint FK143BF46AE8EA6EF6;
[myproject] DEBUG [main] SchemaExport.drop(288) | Unsuccessful: alter table
user_role drop constraint FK143BF46AE8EA6EF6
[myproject] DEBUG [main] SchemaExport.drop(289) | Table not found: USER_ROLE
in statement [alter table user_role]
alter table user_role drop constraint FK143BF46A43BFAB16;
[myproject] DEBUG [main] SchemaExport.execute(303) | alter table user_role
drop constraint FK143BF46A43BFAB16;
[myproject] DEBUG [main] SchemaExport.drop(288) | Unsuccessful: alter table
user_role drop constraint FK143BF46A43BFAB16
[myproject] DEBUG [main] SchemaExport.drop(289) | Table not found: USER_ROLE
in statement [alter table user_role]
drop table address if exists;
[myproject] DEBUG [main] SchemaExport.execute(303) | drop table address if
exists;
drop table app_user if exists;
[myproject] DEBUG [main] SchemaExport.execute(303) | drop table app_user if
exists;
drop table role if exists;
[myproject] DEBUG [main] SchemaExport.execute(303) | drop table role if
exists;
drop table user_role if exists;
[myproject] DEBUG [main] SchemaExport.execute(303) | drop table user_role if
exists;
create table address (id bigint generated by default as identity (start with
1), version integer, address varchar(25) not null, city varchar(25)
not null, country varchar(2) not null, postal_code varchar(25) not null,
province varchar(25) not null, primary key (id));
[myproject] DEBUG [main] SchemaExport.execute(303) | create table address
(id bigint generated by default as identity (start with 1), version int
eger, address varchar(25) not null, city varchar(25) not null, country
varchar(2) not null, postal_code varchar(25) not null, province varchar(25
) not null, primary key (id));
create table app_user (id bigint generated by default as identity (start
with 1), version integer, confirmPassword varchar(255), email varchar(50
) not null, first_name varchar(50) not null, last_name varchar(50) not null,
middle_name varchar(50), password varchar(100) not null, password_hi
nt varchar(50), phone_number varchar(25), username varchar(25) not null,
website varchar(50), address_fk bigint, primary key (id));
[myproject] DEBUG [main] SchemaExport.execute(303) | create table app_user
(id bigint generated by default as identity (start with 1), version in
teger, confirmPassword varchar(255), email varchar(50) not null, first_name
varchar(50) not null, last_name varchar(50) not null, middle_name var
char(50), password varchar(100) not null, password_hint varchar(50),
phone_number varchar(25), username varchar(25) not null, website varchar(50)
, address_fk bigint, primary key (id));
create table role (id bigint generated by default as identity (start with
1), version integer, description varchar(255) not null, name varchar(64
) not null, primary key (id));
[myproject] DEBUG [main] SchemaExport.execute(303) | create table role (id
bigint generated by default as identity (start with 1), version intege
r, description varchar(255) not null, name varchar(64) not null, primary key
(id));
create table user_role (user_id bigint not null, role_id bigint not null,
primary key (user_id, role_id));
[myproject] DEBUG [main] SchemaExport.execute(303) | create table user_role
(user_id bigint not null, role_id bigint not null, primary key (user_
id, role_id));
alter table app_user add constraint FK459C57294AD68248 foreign key
(address_fk) references address;
[myproject] DEBUG [main] SchemaExport.execute(303) | alter table app_user
add constraint FK459C57294AD68248 foreign key (address_fk) references a
ddress;
alter table user_role add constraint FK143BF46AE8EA6EF6 foreign key
(user_id) references app_user;
[myproject] DEBUG [main] SchemaExport.execute(303) | alter table user_role
add constraint FK143BF46AE8EA6EF6 foreign key (user_id) references app
_user;
alter table user_role add constraint FK143BF46A43BFAB16 foreign key
(role_id) references role;
[myproject] DEBUG [main] SchemaExport.execute(303) | alter table user_role
add constraint FK143BF46A43BFAB16 foreign key (role_id) references rol
e;
[myproject] INFO [main] SchemaExport.execute(196) | schema export complete
[myproject] DEBUG [main]
DriverManagerConnectionProvider.closeConnection(129) | returning connection
to pool, pool size: 1
[myproject] INFO [main] DriverManagerConnectionProvider.close(147) |
cleaning up connection pool: jdbc:hsqldb:file:target/testdb-hsql;shutdown=tr
ue
[WARNING] 3 errors occurred while performing <hbm2ddl>.
*[ERROR] Error #1: java.sql.SQLException: Table not found: APP_USER in
statement [alter table app_user]
[ERROR] Error #1: java.sql.SQLException: Table not found: USER_ROLE in
statement [alter table user_role]
[ERROR] Error #1: java.sql.SQLException: Table not found: USER_ROLE in
statement [alter table user_role]
[INFO]
------------------------------------------------------------------------*
I would alos assume that I could point dbvisualizer at this hsql db and I
could see the tables which I can't. It connects, but there are no tables.
--
Thanks,
Mick Knutson
http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---