These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: hibernate.properties not being found
PostPosted: Fri Dec 16, 2011 5:33 pm 
Newbie

Joined: Fri Jan 05, 2007 3:53 pm
Posts: 1
I'm reading Chapter 2 of Harnessing Hibernate, and when generating my db schema, I get an error that a hibernate dialect has not been set.

Code:
drwxr-xr-x 6 leeand00 leeand00 4096 2011-12-16 16:32 .
drwxr-xr-x 3 leeand00 leeand00 4096 2011-12-14 17:07 ..
-rw-r--r-- 1 leeand00 leeand00 3285 2011-12-16 16:22 build.xml
drwxr-xr-x 3 leeand00 leeand00 4096 2011-12-16 16:30 classes
drwxr-xr-x 2 leeand00 leeand00 4096 2011-12-14 17:07 data
drwxr-xr-x 5 leeand00 leeand00 4096 2011-12-16 14:41 .hg
-rw-r--r-- 1 leeand00 leeand00   41 2011-12-16 14:41 .hgignore
drwxr-xr-x 3 leeand00 leeand00 4096 2011-12-16 16:12 src

Project Structure

Code:
BUILD FAILED
/home/leeand00/harnessingHibernate/ch2/example1/build.xml:89: org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
   at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:233)
   at org.hibernate.dialect.Dialect.getDialect(Dialect.java:211)
   at org.hibernate.dialect.Dialect.getDialect(Dialect.java:226)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:86)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:61)
   at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
   at org.apache.tools.ant.Task.perform(Task.java:348)
   at org.apache.tools.ant.Target.execute(Target.java:390)
   at org.apache.tools.ant.Target.performTasks(Target.java:411)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
   at org.apache.tools.ant.Main.runBuild(Main.java:801)
   at org.apache.tools.ant.Main.startAnt(Main.java:218)
   at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
   at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 13 seconds

The Build Error

Code:
<?xml version="1.0" ?>
<project name="Harnessing Hibernate 3 (Developer's Notebook Second Edition)"
         default="db" basedir="."
         xmlns:artifact="antlib:org.apache.maven.artifact.ant">

        <!-- Set up properties containing important project directrories -->
        <property name="source.root" value="src" />
        <property name="class.root" value="classes" />
        <property name="data.dir" value="data" />

        <artifact:dependencies pathId="dependency.classpath">
                <dependency groupId="hsqldb" artifactId="hsqldb"
                            version="1.8.0.7" />

                <dependency groupId="org.hibernate" artifactId="hibernate"
                            version="3.2.5.ga">
                        <exclusion groupId="javax.transaction" artifactId="jta" />
                </dependency>

                <dependency groupId="org.hibernate" artifactId="hibernate-tools"
                            version="3.2.0.beta9a">

                </dependency>

                <dependency groupId="org.apache.geronimo.specs"
                            artifactId="geronimo-jta_1.1_spec" version="1.1" />

                <dependency groupId="log4j" artifactId="log4j" version="1.2.14" />
        </artifact:dependencies>

        <!-- Setup the class path for compliation and execution -->
        <path id="project.class.path">
                <!-- Include our own classes, of course -->
                <pathelement location="${classes.root}" />

                <!-- Add the dependencies classpath -->
                <path refid="dependency.classpath" />
        </path>

        <!-- Teach Ant how to use the Hibernate Tools -->
        <taskdef name="hibernatetool"
                 classname="org.hibernate.tool.ant.HibernateToolTask"
                 classpathref="project.class.path"
        />

...
        <!-- Create our runtime subdirectories and copy resources into them  -->
        <target name="prepare" description="Sets up build structres">
                <mkdir dir="${class.root}" />

                <!-- Copy our property files and O/R mappings for use at runtime  -->
                <copy todir="${class.root}">
                        <fileset dir="${source.root}">
                                <include name="**/*.properties" />
                                <include name="**/*.xml" />
                        </fileset>
                </copy>
        </target>

        <!-- Generate the schemas for all mapping files in our class tree -->
        <target name="schema" depends="prepare"
                description="Generate DB schema from O/R mapping files">
                <hibernatetool destdir="${source.root}">
                        <configuration>
                                <fileset dir="${class.root}">
                                        <include name="**/*.hbm.xml" />
                                </fileset>
                        </configuration>
                        <hbm2ddl drop="yes" />
                </hibernatetool>
        </target>
...

relevant sections of build.xml

I have my hibernate.properties file in my src (${source.root}) directory, and it is copied over to the classes (${class.root}) directory in the dependent prepare <target> before the schema <target> is run.

It appears to me that hibernate.properties is not being found by hbm2ddl.

Should I be placing this file elsewhere?

_________________
No man is an island, that's why we have forums


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.