-->
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.  [ 3 posts ] 
Author Message
 Post subject: not able to generate Pojo using Hibernate3 tools
PostPosted: Thu Jun 26, 2008 5:40 pm 
Newbie

Joined: Thu Jun 26, 2008 5:13 pm
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hello
I am new to this hibernate tools and ant scripts.
I want to generate a simple POJO Using hbm file.I think i was wrong in deciding the correct jar files for this application.Please any one can help to over come this problem.Can any one please find the where i went wrong and what i have to do.It will be a great help if any one can send source code or link for me to illaanil@rediffmail.com
Hibernate version: 3

This is my ant script:

<project default="codegen1" basedir=".">
<property name="src" value="src"/>
<property name="sql" value="sql" />
<property name="hibernate3jars" value="lib/hibernate-3.1.2"/>
<property name="hibernatetools3" value="/lib/hibernate-tools-3.1B4/plugins/org.hibernate.eclipse_3.1.0.beta4/lib/tools"/>
<property name="hsqldbs" value="lib/hsqldb-1.8.0.2/lib"/>
<path id="classpath.base">
<pathelement location="${src}"/>
<pathelement location="${hibernate3jars}/hibernate3.jar"/>
<fileset dir="${hibernate3jars}/lib" includes="**/*.jar"/>
<pathelement location="${hsqldbs}/lib/hsqldb.jar"/>
</path>
<path id="classpath.tools">
<path refid="classpath.base"/>
<pathelement location="${hibernatetools3}/hibernate-tools.jar"/>
</path>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="classpath.tools"/>
<target name="codegen1">
<hibernatetool destdir="${sql}">
<configuration configurationfile="${src}/hibernate.cfg.xml">
<fileset dir="${src}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java />
</hibernatetool>
</target>
</project>



This is the error :


Full stack trace of any exception that occurs:

ader
[hibernatetool] Jun 27, 2008 2:52:52 AM org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoToString.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] Jun 27, 2008 2:52:52 AM org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoEqualsHashcode.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] Jun 27, 2008 2:52:52 AM org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] SEVERE: Method needsEqualsHashCode threw exception for reference $pojo in template pojo/PojoEqualsHashcode.vm at [1,5]
[hibernatetool] Jun 27, 2008 2:52:52 AM org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] SEVERE: Method get threw exception for reference $templates in template pojo/Pojo.vm at [17,1]

BUILD FAILED
C:\Ant\bin\hibernate\build.xml:28: org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while processing template Pojo. Invocation of meth
od 'get' in class org.hibernate.tool.hbm2x.TemplateHelper$Templates threw exception class org.hibernate.tool.hbm2x.ExporterException : MethodInvocationExc
eption while processing template pojo/PojoEqualsHashcode.vm. Invocation of method 'needsEqualsHashCode' in class org.hibernate.tool.hbm2x.pojo.EntityPOJOC
lass threw exception class java.lang.NoSuchMethodError : org.hibernate.mapping.Property.isNaturalIdentifier()Z

Total time: 1 second

This are my cfg file :

<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:hsqldb:file:testdb;shutdown=true</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">0</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>

<!-- You will usually want to set this to true while debugging Hibernate queries -->
<property name="hibernate.show_sql">true</property>

<!--
<mapping resource="sample/entity/lazy/User.hbm.xml"/>
<mapping resource="sample/entity/lazy/Email.hbm.xml"/>
-->
</session-factory>
</hibernate-configuration>



This is my mapping file :



<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="sample.entity.lazy.Email" table="lazy_email">

<id access="field" name="id" type="int" column="id">
<generator class="native"/>
</id>

<property access="field" name="email" column="name" type="string" unique="true"/>

</class>
</hibernate-mapping>





Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 12, 2008 7:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I can see you are using .vm files (Velocity) which is something hibernate tools haven't used for almost 2 years now plus it seem you are using an incompatible hibernate3.jar with it.

Please use an uptodate version of Hibernate Tools/Hibernate.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 4:24 pm 
Newbie

Joined: Thu Mar 17, 2005 2:06 pm
Posts: 12
It might be easier to write your Java objects and then have a tool generate your sql statements and hibernate config files. Here is one tool that does it: http://www.javatosql.com


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

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.