Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.0
Mapping documents: Annotations in class files
Name and version of the database you are using: Postgresql 8.3
The generated SQL (show_sql=true): None - that's the problem
Debug level Hibernate log excerpt:
I am trying to generate schema from Annotated classes. I run the ant task with hbm2ddl and it says it's exporting the schema, but in reality it does nothing.
hibernate.cfg.xml:
<?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>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost/tmd</property>
<property name="connection.username">plexq</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping class="com.tmdworldwide.db.Client"/>
<mapping class="com.tmdworldwide.db.File"/>
<mapping class="com.tmdworldwide.db.Message"/>
<mapping class="com.tmdworldwide.db.Product"/>
<mapping class="com.tmdworldwide.db.Project"/>
<mapping class="com.tmdworldwide.db.Role"/>
<mapping class="com.tmdworldwide.db.TimesheetEntry"/>
<mapping class="com.tmdworldwide.db.User"/>
<mapping class="com.tmdworldwide.db.Workflow"/>
<mapping class="com.tmdworldwide.db.WorkflowItem"/>
<mapping class="com.tmdworldwide.db.WorkflowItemHistory"/>
<mapping class="com.tmdworldwide.db.WorkflowMaster"/>
<mapping class="com.tmdworldwide.db.WorkflowMasterItem"/>
<mapping class="com.tmdworldwide.db.WorkItem"/>
</session-factory>
</hibernate-configuration>
ant task:
<target name="schema" depends="init, compile">
<hibernatetool destdir="${src}">
<classpath refid="project.class.path"/>
<annotationconfiguration configurationfile="${src}/hibernate.cfg.xml"/>
<hbm2ddl drop="yes"/>
</hibernatetool>
</target>
output from ant:
alex-turners-imac:project-manager plexq$ ant schema
Buildfile: build.xml
init:
compile:
schema:
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] log4j:WARN No such property [maxFileSize] in org.apache.log4j.DailyRollingFileAppender.
[hibernatetool] log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFileAppender.
[hibernatetool] 21:10:28: INFO org.hibernate.cfg.annotations.Version (Version.java:15) - Hibernate Annotations 3.2.0.GA
[hibernatetool] 21:10:28: INFO org.hibernate.cfg.Environment (Environment.java:500) - Hibernate 3.2.0.cr5
[hibernatetool] 21:10:28: INFO org.hibernate.cfg.Environment (Environment.java:533) - hibernate.properties not found
[hibernatetool] 21:10:28: INFO org.hibernate.cfg.Environment (Environment.java:667) - Bytecode provider name : cglib
[hibernatetool] 21:10:28: INFO org.hibernate.cfg.Environment (Environment.java:584) - using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 21:10:28: INFO org.hibernate.cfg.Configuration (Configuration.java:1384) - configuring from file: hibernate.cfg.xml
[hibernatetool] 21:10:29: INFO org.hibernate.cfg.Configuration (Configuration.java:1465) - Configured SessionFactory: null
[hibernatetool] 21:10:29: INFO org.hibernate.dialect.Dialect (Dialect.java:141) - Using dialect: org.hibernate.dialect.PostgreSQLDialect
[hibernatetool] 21:10:29: INFO org.hibernate.tool.hbm2ddl.SchemaExport (SchemaExport.java:154) - Running hbm2ddl schema export
[hibernatetool] 21:10:29: INFO org.hibernate.tool.hbm2ddl.SchemaExport (SchemaExport.java:179) - exporting generated schema to database
[hibernatetool] 21:10:29: INFO org.hibernate.connection.DriverManagerConnectionProvider (DriverManagerConnectionProvider.java:41) - Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] 21:10:29: INFO org.hibernate.connection.DriverManagerConnectionProvider (DriverManagerConnectionProvider.java:42) - Hibernate connection pool size: 1
[hibernatetool] 21:10:29: INFO org.hibernate.connection.DriverManagerConnectionProvider (DriverManagerConnectionProvider.java:45) - autocommit mode: false
[hibernatetool] 21:10:29: INFO org.hibernate.connection.DriverManagerConnectionProvider (DriverManagerConnectionProvider.java:80) - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost/tmd
[hibernatetool] 21:10:29: INFO org.hibernate.connection.DriverManagerConnectionProvider (DriverManagerConnectionProvider.java:86) - connection properties: {user=plexq, password=****}
[hibernatetool] 21:10:29: INFO org.hibernate.tool.hbm2ddl.SchemaExport (SchemaExport.java:196) - schema export complete
[hibernatetool] 21:10:29: INFO org.hibernate.connection.DriverManagerConnectionProvider (DriverManagerConnectionProvider.java:147) - cleaning up connection pool: jdbc:postgresql://localhost/tmd
BUILD SUCCESSFUL
Total time: 1 second