Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I wanted to use hbm2ddl from ant task with small entity - the tool is running, but the output file is empty.
Hibernate version:
hibernate tools 2.2.1.beta1 (eclipse plugin)
Hibernate conf:
<?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 name="sessionFactory">
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost/xdb</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.show_sql">true</property>
<mapping class="pl.entity.Test"/>
</session-factory>
</hibernate-configuration>
task call:
<hibernatetool destdir=".">
<annotationconfiguration configurationfile="src\main\resources\hibernate.cfg.xml" />
<hbm2ddl export="false" outputfilename="ddl.sql"
drop="true" create="true" haltonerror="true"
format="true" delimiter=";"/>
</hibernatetool>
tool output:
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 12:53:13 INFO - Version.<clinit>(15) | Hibernate Annotations 3.3.0.GA
[hibernatetool] 12:53:13 INFO - Environment.<clinit>(514) | Hibernate 3.2.5
[hibernatetool] 12:53:13 INFO - Environment.<clinit>(547) | hibernate.properties not found
[hibernatetool] 12:53:13 INFO - Environment.buildBytecodeProvider(681) | Bytecode provider name : cglib
[hibernatetool] 12:53:13 INFO - Environment.<clinit>(598) | using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 12:53:14 INFO - Configuration.configure(1460) | configuring from file: hibernate.cfg.xml
[hibernatetool] 12:53:14 DEBUG - DTDEntityResolver.resolveEntity(38) | trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
[hibernatetool] 12:53:14 DEBUG - DTDEntityResolver.resolveEntity(40) | recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[hibernatetool] 12:53:14 DEBUG - DTDEntityResolver.resolveEntity(50) | located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
[hibernatetool] 12:53:14 DEBUG - Configuration.addProperties(1387) | hibernate.connection.driver_class=org.hsqldb.jdbcDriver
[hibernatetool] 12:53:14 DEBUG - Configuration.addProperties(1387) | hibernate.connection.url=jdbc:hsqldb:hsql://localhost/xdb
[hibernatetool] 12:53:14 DEBUG - Configuration.addProperties(1387) | hibernate.connection.username=sa
[hibernatetool] 12:53:14 DEBUG - Configuration.addProperties(1387) | hibernate.dialect=org.hibernate.dialect.HSQLDialect
[hibernatetool] 12:53:14 DEBUG - Configuration.addProperties(1387) | hibernate.show_sql=true
[hibernatetool] 12:53:14 DEBUG - AnnotationConfiguration.parseMappingElement(596) | sessionFactory<-org.dom4j.tree.DefaultAttribute@152513a [Attribute: name class value "pl.entity.Test"]
[hibernatetool] 12:53:14 INFO - Configuration.doConfigure(1541) | Configured SessionFactory: sessionFactory
[hibernatetool] 12:53:14 DEBUG - Configuration.doConfigure(1542) | properties: {java.runtime.name=Java(TM) SE Runtime Environment, [.......]
[hibernatetool] 12:53:14 DEBUG - AnnotationConfiguration.secondPassCompile(244) | Execute first pass mapping processing
[hibernatetool] 12:53:14 DEBUG - AnnotationConfiguration.processArtifactsOfType(481) | Process hbm files
[hibernatetool] 12:53:14 DEBUG - AnnotationConfiguration.processArtifactsOfType(489) | Process annotated classes
[hibernatetool] 12:53:14 DEBUG - AnnotationConfiguration.processFkSecondPassInOrder(375) | processing manytoone fk mappings
[hibernatetool] 12:53:14 DEBUG - Configuration.secondPassCompile(1120) | processing extends queue
[hibernatetool] 12:53:14 DEBUG - Configuration.secondPassCompile(1124) | processing collection mappings
[hibernatetool] 12:53:14 DEBUG - Configuration.secondPassCompile(1135) | processing native query and ResultSetMapping mappings
[hibernatetool] 12:53:14 DEBUG - Configuration.secondPassCompile(1143) | processing association property references
[hibernatetool] 12:53:14 DEBUG - Configuration.secondPassCompile(1165) | processing foreign key constraints
[hibernatetool] 12:53:14 INFO - Dialect.<init>(152) | Using dialect: org.hibernate.dialect.HSQLDialect
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.secondPassCompile(244) | Execute first pass mapping processing
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.processArtifactsOfType(481) | Process hbm files
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.processArtifactsOfType(489) | Process annotated classes
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.processFkSecondPassInOrder(375) | processing manytoone fk mappings
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1120) | processing extends queue
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1124) | processing collection mappings
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1135) | processing native query and ResultSetMapping mappings
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1143) | processing association property references
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1165) | processing foreign key constraints
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.secondPassCompile(244) | Execute first pass mapping processing
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.processArtifactsOfType(481) | Process hbm files
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.processArtifactsOfType(489) | Process annotated classes
[hibernatetool] 12:53:15 DEBUG - AnnotationConfiguration.processFkSecondPassInOrder(375) | processing manytoone fk mappings
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1120) | processing extends queue
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1124) | processing collection mappings
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1135) | processing native query and ResultSetMapping mappings
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1143) | processing association property references
[hibernatetool] 12:53:15 DEBUG - Configuration.secondPassCompile(1165) | processing foreign key constraints
[hibernatetool] 12:53:15 INFO - SchemaExport.execute(154) | Running hbm2ddl schema export
[hibernatetool] 12:53:15 DEBUG - SchemaExport.execute(170) | import file not found: /import.sql
[hibernatetool] 12:53:15 INFO - SchemaExport.execute(174) | writing generated schema to file: C:\workspace\maven\spring.research\ddl.sql
[hibernatetool] 12:53:15 INFO - SchemaExport.execute(196) | schema export complete
Entity class:
package pl.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Test {
private long id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Column(name="asddddd")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String name;
}
I've also found out that :
the entity class is found ( if I specify wrong name - there is an error.)
when class Test specified in configuration is not a javax.persistence.Entity annotated - there is no information about that - no error,
so I assume something is wrong with the entity configuration.
Many thanks for some suggestion.