Hello,
I've set up hibernate in a project, especially ant hibernate tools.
In order to test this, I've created a Person table, all goes well, hibernate connects to the database, but the table is not created, maybe I forgot something?
Here are hibernate traces:
Code:
updateSchemaJPA:
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 00:12:26,673 INFO Version:37 – Hibernate Commons Annotations 3.2.0.Final
[hibernatetool] 00:12:26,687 INFO Environment:593 – Hibernate 3.6.1.Final
[hibernatetool] 00:12:26,690 INFO Environment:626 – hibernate.properties not found
[hibernatetool] 00:12:26,695 INFO Environment:804 – Bytecode provider name : javassist
[hibernatetool] 00:12:26,700 INFO Environment:685 – using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 00:12:26,809 INFO Version:42 – Hibernate EntityManager 3.6.1.Final
[hibernatetool] 00:12:27,012 INFO Configuration:1646 – Hibernate Validator not found: ignoring
[hibernatetool] 00:12:27,043 INFO Dialect:135 – Using dialect: org.hibernate.dialect.PostgreSQLDialect
[hibernatetool] 00:12:27,074 INFO SchemaExport:234 – Running hbm2ddl schema export
[hibernatetool] 00:12:27,074 INFO SchemaExport:262 – exporting generated schema to database
[hibernatetool] 00:12:27,074 INFO DriverManagerConnectionProvider:64 – Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] 00:12:27,074 INFO DriverManagerConnectionProvider:65 – Hibernate connection pool size: 20
[hibernatetool] 00:12:27,074 INFO DriverManagerConnectionProvider:68 – autocommit mode: true
[hibernatetool] 00:12:27,090 INFO DriverManagerConnectionProvider:103 – using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5400/poker
[hibernatetool] 00:12:27,090 INFO DriverManagerConnectionProvider:109 – connection properties: {user=postgres, password=****, autocommit=true, release_mode=auto}
[hibernatetool] 00:12:27,274 INFO SchemaExport:281 – schema export complete
[hibernatetool] 00:12:27,279 INFO DriverManagerConnectionProvider:170 – cleaning up connection pool: jdbc:postgresql://localhost:5400/poker
BUILD SUCCESSFUL
Total time: 1 second
The Person entity :
Code:
@Entity
public class Person {
@Id @GeneratedValue
private int personId;
@Column(length=30)
private String firstName;
@Column(length=30)
private String name;
public int getPersonId() {
return personId;
}
public void setPersonId(int personId) {
this.personId = personId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
And my ant tasks :
Code:
<target name="updateSchemaJPA" depends="defineHibernateTool">
<hibernatetool destdir="./data">
<jpaconfiguration persistenceunit="${persistence.unit}"/>
<classpath>
<path location="./build/classes"/>
<path location="./persistence"/>
</classpath>
<hbm2ddl/>
</hibernatetool>
</target>
<target name="defineHibernateTool">
<path id="jpatoolslib">
<fileset dir="./WebContent/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${tomcatruntimelib}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="jpatoolslib" />
</target>