Hi,
I'm trying to create java files from an existing database schema.
But hibernate tool does not generate code ... but it also does not generate an error.
I think the problem is that sessionfactory is null, but I don't know why.
When I use the hibernate.cfg.xml in my application I'm getting a connection
hibernate.cfg.xml
Code:
<?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>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/schufa</property>
<property name="connection.username">root</property>
<property name="hibernate.hbm2ddl.auto">validate</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</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>
</session-factory>
</hibernate-configuration>
Ant Task:
Code:
<project basedir="." default="hibernate">
<!-- <property name="jdbc.driver.jar" value="C:/Program Files/Oracle/ora91/jdbc/lib/ojdbc14.jar" /> -->
<property name="jdbc.driver.jar" value="../../IWAModCore/lib/mysql-connector-java-5.1.6-bin.jar" />
<path id="toolslib">
<path location="../../IWAModCore/lib/hibernate-tools.jar" />
<path location="../../IWAWeb/WebContent/WEB-INF/lib/hibernate3.jar" />
<path location="../../IWAWeb/WebContent/WEB-INF/lib/freemarker-2.3.8.jar" />
<path location="../../IWAWeb/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar" />
<path location="../../IWAWeb/WebContent/WEB-INF/lib/dom4j-1.6.1.jar" />
<path location="${jdbc.driver.jar}" />
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" />
<property name="gen.dir" location="${basedir}/hibernate/gen"/>
<target name="hibernate">
<mkdir dir="${gen.dir}"/>
<hibernatetool destdir="${gen.dir}">
<configuration configurationfile="../src/hibernate.cfg.schufa.xml"/>
<hbm2java ejb3="true" jdk5="true" />
</hibernatetool>
</target>
</project>
Output:
Code:
parsing buildfile C:\Workspaces\workspace_iwa\IWAModSchufa\hibernate\build.xml with URI = file:///C:/Workspaces/workspace_iwa/IWAModSchufa/hibernate/build.xml
Project base dir set to: C:\Workspaces\workspace_iwa\IWAModSchufa\hibernate
Build sequence for target(s) `hibernate' is [hibernate]
Complete build sequence is [hibernate, ]
hibernate:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] 24.07.2008 16:19:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.6
[hibernatetool] 24.07.2008 16:19:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 24.07.2008 16:19:16 org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] 24.07.2008 16:19:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 24.07.2008 16:19:17 org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.schufa.xml
[hibernatetool] 24.07.2008 16:19:17 org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: null
[hibernatetool] 24.07.2008 16:19:17 org.hibernate.tool.Version <clinit>
[hibernatetool] INFO: Hibernate Tools 3.2.1.GA
BUILD SUCCESSFUL
Total time: 907 milliseconds