Hello,
I am trying to build the "eg" examples under Maven 1.0.2. Maven is much stricter when it comes to the dependencies and I am finding myself guessing which version Hibernate is using and what libraries are actually required for the eg examples...
Anyone managed to build (and RUN) the eg example under a simple maven jar?
Could you post your Dependencies?
Did you have to change any code?
Did you manage to CREATE the DB schema (looks like removing the FK is failing and everything from there on...)
I have reached the point where it does compile and connects to the database (MySQL) but it does not seem to be able to generate the schema! See the difference between the ANT run and the MAVEN run:
Many thanks!
ANT:
Code:
[java] 20:17:36,377 INFO Configuration:917 - processing foreign key constraints
[java] 20:17:36,498 INFO SchemaExport:113 - Running hbm2ddl schema export
[java] 20:17:36,508 INFO SchemaExport:129 - exporting generated schema to database
[java] 20:17:36,518 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[java] 20:17:36,518 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[java] 20:17:36,518 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[java] 20:17:36,518 INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///testhibernate
[java] 20:17:36,518 INFO DriverManagerConnectionProvider:86 - connection properties: {user=root, password=****}
[java] 20:17:36,628 DEBUG SchemaExport:143 - alter table AuctionItem drop foreign key FK522A9BD61107FE9B
[java] 20:17:36,818 DEBUG SchemaExport:143 - alter table AuctionItem drop foreign key FK522A9BD6F65B1FAF
[java] 20:17:36,988 DEBUG SchemaExport:143 - alter table Bid drop foreign key FK104DDEE6E7E98
[java] 20:17:37,189 DEBUG SchemaExport:143 - alter table Bid drop foreign key FK104DDF43A3910
[java] 20:17:37,369 DEBUG SchemaExport:143 - drop table if exists AuctionItem
[java] 20:17:37,399 DEBUG SchemaExport:143 - drop table if exists AuctionUser
[java] 20:17:37,439 DEBUG SchemaExport:143 - drop table if exists Bid
[java] 20:17:37,479 DEBUG SchemaExport:161 - create table AuctionItem (
[java] id bigint not null auto_increment,
[java] seller bigint not null,
[java] description varchar(200) not null,
[java] ends datetime,
[java] condition integer,
[java] successfulBid bigint,
[java] primary key (id),
[java] unique (seller, description)
[java] ) comment 'An item that is being auctioned.' type=InnoDB
[java] 20:17:37,629 DEBUG SchemaExport:161 - create table AuctionUser (
MAVENCode:
20:52:41,474 INFO Configuration:917 - processing foreign key constraints
20:52:41,484 INFO SchemaExport:113 - Running hbm2ddl schema export
20:52:41,494 INFO SchemaExport:129 - exporting generated schema to database
20:52:41,504 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
20:52:41,504 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
20:52:41,514 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
20:52:41,524 INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///testhibernate
20:52:41,535 INFO DriverManagerConnectionProvider:86 - connection properties: {user=root, password=****}
20:52:41,585 DEBUG SchemaExport:143 - alter table AuctionItem drop foreign key FK522A9BD651F579EE
20:52:41,855 DEBUG SchemaExport:149 - *******Unsuccessful: alter table AuctionItem drop foreign key FK522A9BD651F579EE*******
20:52:41,855 DEBUG SchemaExport:150 - *******Error on rename of '.\testhibernate\auctionitem' to '.\testhibernate\#sql2-314-48' (errno: 152)*******
20:52:41,865 DEBUG SchemaExport:143 - alter table AuctionItem drop foreign key FK522A9BD68F76DFC
20:52:42,015 DEBUG SchemaExport:149 - *******Unsuccessful: alter table AuctionItem drop foreign key FK522A9BD68F76DFC*******
20:52:42,015 DEBUG SchemaExport:150 - *******Error on rename of '.\testhibernate\auctionitem' to '.\testhibernate\#sql2-314-48' (errno: 152)*******
20:52:42,025 DEBUG SchemaExport:143 - alter table Bid drop foreign key FK104DD17722FE5
20:52:42,185 DEBUG SchemaExport:149 - *******Unsuccessful: alter table Bid drop foreign key FK104DD17722FE5*******
20:52:42,185 DEBUG SchemaExport:150 - *******Error on rename of '.\testhibernate\bid' to '.\testhibernate\#sql2-314-48' (errno: 152)*******
20:52:42,195 DEBUG SchemaExport:143 - alter table Bid drop foreign key FK104DD3527B463
20:52:42,346 DEBUG SchemaExport:149 - *******Unsuccessful: alter table Bid drop foreign key FK104DD3527B463*******
20:52:42,356 DEBUG SchemaExport:150 - *******Error on rename of '.\testhibernate\bid' to '.\testhibernate\#sql2-314-48' (errno: 152)*******
20:52:42,366 DEBUG SchemaExport:143 - drop table if exists AuctionItem
20:52:42,376 DEBUG SchemaExport:149 - *******Unsuccessful: drop table if exists AuctionItem*******
20:52:42,376 DEBUG SchemaExport:150 - *******Cannot delete or update a parent row: a foreign key constraint fails*******
20:52:42,386 DEBUG SchemaExport:143 - drop table if exists AuctionUser
20:52:42,396 DEBUG SchemaExport:149 - *******Unsuccessful: drop table if exists AuctionUser*******
20:52:42,406 DEBUG SchemaExport:150 - *******Cannot delete or update a parent row: a foreign key constraint fails*******
20:52:42,416 DEBUG SchemaExport:143 - drop table if exists Bid
20:52:42,426 DEBUG SchemaExport:149 - *******Unsuccessful: drop table if exists Bid*******
20:52:42,436 DEBUG SchemaExport:150 - *******Cannot delete or update a parent row: a foreign key constraint fails*******
20:52:42,446 DEBUG SchemaExport:161 - create table AuctionItem (
id bigint not null auto_increment,
seller bigint not null,
description varchar(200) not null,
ends datetime,
condition integer,
successfulBid bigint,
primary key (id),
unique (seller, description)
) comment 'An item that is being auctioned.' type=InnoDB
20:52:42,536 ERROR SchemaExport:167 - *******Unsuccessful: create table AuctionItem (id bigint not null auto_increment, seller bigint not null, description v
archar(200) not null, ends datetime, condition integer, successfulBid bigint, primary key (id), unique (seller, description)) comment 'An item that is
being auctioned.' type=InnoDB*******
20:52:42,556 ERROR SchemaExport:168 - *******Table 'auctionitem' already exists*******
20:52:42,566 DEBUG SchemaExport:161 - create table AuctionUser (
Here is my set of dependencies (probably OTT and
may be wrong???)
Code:
<dependencies>
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.0.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>2.1.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>1.6.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>1.5.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-attrs</artifactId>
<version>1.5.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly</artifactId>
<version>1.0-beta-4</version>
<url>http://jakarta.apache.org/commons/jelly/</url>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-betwixt</groupId>
<artifactId>commons-betwixt</artifactId>
<version>1.0-alpha-1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>1.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>2.1.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0.b2</version>
<url>http://xml.apache.org/xerces2-j/</url>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.6.2</version>
<url>http://xml.apache.org/xerces2-j/</url>
</dependency>
<dependency>
<groupId>odmg</groupId>
<artifactId>odmg</artifactId>
<version>3.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>jta</groupId>
<artifactId>jta</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>3.1.10</version>
<type>jar</type>
</dependency>
</dependencies>
Hibernate version: 3.0.5
Mapping documents: as per "Getting Started" examples
Code between sessionFactory.openSession() and session.close():Code:
Configuration cfg = new Configuration().addClass(AuctionItem.class)
.addClass(Bid.class).addClass(User.class).setProperty(
Environment.HBM2DDL_AUTO, "create");
Full stack trace of any exception that occurs:
see above.
Name and version of the database you are using:
MySQL 4.1 (works under Ant)
The generated SQL (show_sql=true):
see above
Debug level Hibernate log excerpt: