-->
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.  [ 11 posts ] 
Author Message
 Post subject: hbm2java: does not geneate ID getter/setter
PostPosted: Sun Mar 13, 2005 1:44 pm 
Beginner
Beginner

Joined: Mon Mar 07, 2005 9:15 am
Posts: 26
Hi,

I am using the hbm2java Ant task to generate the POJOs. Unfortunatelly
the ID's getter and setter is not generated. I assume we don't require a <property>
for this.

I suspect my set-up/configration may be to blame. Specifically, I see that when
hbm2java executes, it always seems to try and load te properties file independent
of the XML configuration file.

Hibernate version:
Hibernate 3.0
Hibernate tools 3.0 alpha

Mapping documents:

Class mappiing
..........................

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="pt">

<class
name="Child"
table="browser.actor"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
where="g1='R' AND g2='W'"
>

<id
name="id"
column="idactor"
type="long"
>
<generator class="sequence">
<param name="sequence">idactor_seq</param>
</generator>
</id>

<property
name="name"
type="string"
update="true"
insert="true"
access="property"
column="nameac"
/>

<property
name="email"
type="string"
update="true"
insert="true"
access="property"
column="email"
/>

<property
name="address"
type="string"
update="true"
insert="true"
access="property"
column="address"
/>

<!-- many-to-one
name="accommodationType"
class="Parent"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="property"
column="typela"
not-null="true"
/ -->

</class>

</hibernate-mapping>

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

HBM2Java Configuation file
.............................................


<hibernate-configuration>

<session-factory name="linkall">

<!-- properties -->
<property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>

<property name="connection.username">hugof</property>
<property name="connection.driver_class">org.postgresql.jdbc2.optional.PoolingDataSource</property>
<property name="connection.url">jdbc:postgresql://localhost/browser</property>

<!-- mapping files -->
<mapping resource="pt/Child.hbm.xml"/>
<mapping resource="pt/Parent.hbm.xml"/>

</session-factory>

<codegen>
<generate renderer="org.hibernate.tool.hbm2java.BasicRenderer">
<param name="generate-concrete-empty-classes">false</param>
</generate>
<generate
package="autofinders.only"
suffix="Finder"
renderer="org.hibernate.tool.hbm2java.FinderRenderer"/>
</codegen>

</hibernate-configuration>

Ant Task
.................

<target name="generatesources">
<taskdef name="generatesources"
classname="org.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="hibernate.classpath">
</taskdef>

<generatesources config="${src}/hbm2java.cfg.xml"
output="${src}"
>
<fileset dir="${src}">
<include name="pt/**/*.hbm.xml" />
</fileset>
</generatesources>
</target>

Code between sessionFactory.openSession() and session.close():
None

Full stack trace of any exception that occurs:

org.hibernate.PropertyNotFoundException: Could not find a getter for id in class pt.Child
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:213)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:207)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:148)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:41)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:104)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:398)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at Test.testCreateActor(Test.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:72)
at junit.textui.TestRunner.run(TestRunner.java:57)
at Test.main(Test.java:39)


Name and version of the database you are using:
PostgreSQL 7.4

The generated SQL (show_sql=true):
none

Debug level Hibernate log excerpt:
generatesources:
[generatesources] Processing 2 files.
[generatesources] Building hibernate objects
[generatesources] 13 Mar 2005 17:20:11.171 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
[generatesources] 13 Mar 2005 17:20:11.175 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
[generatesources] 13 Mar 2005 17:20:11.293 [INFO] [main] [org.hibernate.cfg.Environment] - Hibernate 3.0rc1
[generatesources] 13 Mar 2005 17:20:11.296 [INFO] [main] [org.hibernate.cfg.Environment] - hibernate.properties not found
[generatesources] 13 Mar 2005 17:20:11.300 [INFO] [main] [org.hibernate.cfg.Environment] - using CGLIB reflection optimizer
[generatesources] 13 Mar 2005 17:20:11.304 [INFO] [main] [org.hibernate.cfg.Environment] - using JDK 1.4 java.sql.Timestamp handling
[generatesources] 13 Mar 2005 17:20:11.306 [INFO] [main] [org.hibernate.cfg.Configuration] - Mapping file: /home/hugof/workspace/hiber3/src/pt/Child.hbm.xml
[generatesources] 13 Mar 2005 17:20:11.427 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
[generatesources] 13 Mar 2005 17:20:11.430 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
[generatesources] 13 Mar 2005 17:20:11.684 [INFO] [main] [org.hibernate.cfg.HbmBinder] - Mapping class: pt.Child -> browser.actor
[generatesources] 13 Mar 2005 17:20:11.696 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: id -> idactor
[generatesources] 13 Mar 2005 17:20:11.723 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: name -> nameac
[generatesources] 13 Mar 2005 17:20:11.727 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: email -> email
[generatesources] 13 Mar 2005 17:20:11.728 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: address -> address
[generatesources] 13 Mar 2005 17:20:11.730 [INFO] [main] [org.hibernate.cfg.Configuration] - processing extends queue
[generatesources] 13 Mar 2005 17:20:11.731 [INFO] [main] [org.hibernate.cfg.Configuration] - processing collection mappings
[generatesources] 13 Mar 2005 17:20:11.732 [INFO] [main] [org.hibernate.cfg.Configuration] - processing association property references
[generatesources] 13 Mar 2005 17:20:11.736 [INFO] [main] [org.hibernate.cfg.Configuration] - processing foreign key constraints
[generatesources] 13 Mar 2005 17:20:11.742 [DEBUG] [main] [org.hibernate.tool.hbm2java.ClassMapping] - Processing mapping for class: pt.Child
[generatesources] 13 Mar 2005 17:20:11.768 [INFO] [main] [org.hibernate.tool.hbm2java.FieldProperty] - fieldname = name
[generatesources] 13 Mar 2005 17:20:11.924 [INFO] [main] [org.hibernate.tool.hbm2java.FieldProperty] - fieldname = email
[generatesources] 13 Mar 2005 17:20:11.925 [INFO] [main] [org.hibernate.tool.hbm2java.FieldProperty] - fieldname = address
[generatesources] 13 Mar 2005 17:20:11.927 [INFO] [main] [org.hibernate.tool.hbm2java.Generator] - Generating 1 in /home/hugof/workspace/hiber3/src
[generatesources] 13 Mar 2005 17:20:11.964 [DEBUG] [main] [org.hibernate.tool.hbm2java.Generator] - Writing /home/hugof/workspace/hiber3/src/pt/Child.java
[generatesources] 13 Mar 2005 17:20:11.979 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
[generatesources] 13 Mar 2005 17:20:11.982 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
[generatesources] 13 Mar 2005 17:20:11.990 [INFO] [main] [org.hibernate.cfg.Configuration] - Mapping file: /home/hugof/workspace/hiber3/src/pt/Parent.hbm.xml
[generatesources] 13 Mar 2005 17:20:11.993 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
[generatesources] 13 Mar 2005 17:20:11.995 [DEBUG] [main] [org.hibernate.util.DTDEntityResolver] - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
[generatesources] 13 Mar 2005 17:20:12.029 [INFO] [main] [org.hibernate.cfg.HbmBinder] - Mapping class: pt.Parent -> browser.typelocalactor
[generatesources] 13 Mar 2005 17:20:12.032 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: id -> idtla
[generatesources] 13 Mar 2005 17:20:12.033 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: name -> nametla
[generatesources] 13 Mar 2005 17:20:12.035 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: description -> desctla
[generatesources] 13 Mar 2005 17:20:12.036 [INFO] [main] [org.hibernate.cfg.Configuration] - processing extends queue
[generatesources] 13 Mar 2005 17:20:12.037 [INFO] [main] [org.hibernate.cfg.Configuration] - processing collection mappings
[generatesources] 13 Mar 2005 17:20:12.039 [INFO] [main] [org.hibernate.cfg.Configuration] - processing association property references
[generatesources] 13 Mar 2005 17:20:12.041 [INFO] [main] [org.hibernate.cfg.Configuration] - processing foreign key constraints
[generatesources] 13 Mar 2005 17:20:12.045 [DEBUG] [main] [org.hibernate.tool.hbm2java.ClassMapping] - Processing mapping for class: pt.Parent
[generatesources] 13 Mar 2005 17:20:12.046 [INFO] [main] [org.hibernate.tool.hbm2java.FieldProperty] - fieldname = name
[generatesources] 13 Mar 2005 17:20:12.050 [INFO] [main] [org.hibernate.tool.hbm2java.FieldProperty] - fieldname = description
[generatesources] 13 Mar 2005 17:20:12.095 [INFO] [main] [org.hibernate.tool.hbm2java.Generator] - Generating 1 in /home/hugof/workspace/hiber3/src
[generatesources] 13 Mar 2005 17:20:12.097 [DEBUG] [main] [org.hibernate.tool.hbm2java.Generator] - Writing /home/hugof/workspace/hiber3/src/pt/Parent.java
BUILD SUCCESSFUL
Total time: 2 seconds

Please note that when generating I have the output:
[INFO] [main] [org.hibernate.cfg.HbmBinder] - Mapping class: pt.Child -> browser.actor
[generatesources] 13 Mar 2005 17:20:11.696 [DEBUG] [main] [org.hibernate.cfg.HbmBinder] - Mapped property: id -> idactor

Which indicates that the id is in fact read.

Appreciate any pointers.

TIA,
Hugo Ferreira.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 13, 2005 3:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
same reply as to your other posting

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 4:06 am 
Beginner
Beginner

Joined: Mon Mar 07, 2005 9:15 am
Posts: 26
Thanks for the reply.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 11:29 am 
Beginner
Beginner

Joined: Mon Mar 07, 2005 9:15 am
Posts: 26
Update: see http://forum.hibernate.org/viewtopic.php?t=939877 for more information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 9:27 am 
Newbie

Joined: Fri Apr 22, 2005 5:23 am
Posts: 4
I'm still getting same problem. hbm2Java doesnot generate id setter/getter methods. I downloaded Hibernate 3 and hibernate-tools-3.0alpha1 yesterday.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 9:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
add minimal failing test to jira.

I have a very hard time belive it is not generating it since the unittest would fail if not - so be very sure ,)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 10:29 am 
Newbie

Joined: Fri Apr 22, 2005 5:23 am
Posts: 4
done

http://opensource.atlassian.com/project ... se/HBX-238


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 10:30 am 
Newbie

Joined: Fri Apr 22, 2005 5:23 am
Posts: 4
mdusad wrote:



PS: I have not generated Hibernate3 and Hibernate Tools from cvs. I took the latest zip files.


Top
 Profile  
 
 Post subject: Same Problem
PostPosted: Mon May 16, 2005 6:14 pm 
Newbie

Joined: Mon May 16, 2005 6:03 pm
Posts: 7
Location: Grand Rapids, MI, USA
I get the same problem. Hibernate does not generate id getter and setters. I have downloaded the latest Hibernate 3.0.3 and Hibernate-Tools-3.0alpha.

i have pulled hibernate-tools from cvs with no luck...

I am trying to learn hibernate. Any assistance? I have googled, searched this forum and asked in the #hibernate irc channel on freenode.net with no luck.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 10:24 pm 
Newbie

Joined: Mon May 16, 2005 6:03 pm
Posts: 7
Location: Grand Rapids, MI, USA
I confirmed it. I checked out both Hibernate3 and HibernateExt from cvs and it still doesn't work. I even tried compiling stuff from the test/ directory in Hibernate3....and it didn't work there.

Anyone please point me in a right direction? thanks,

Zach


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 11:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hi,

confirmed what ? the unit tests passes and generates id all over the place.

The only way i can reproduce this is by:

A. using a *old* hibernate-tools.jar
B. using the *old* and now deleted hbm2java ant task

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.