-->
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: missing primary key property with hbm2java
PostPosted: Fri Mar 11, 2005 10:01 am 
Newbie

Joined: Thu Jan 20, 2005 9:12 am
Posts: 4
I'm generating SQL and Java from the mapping file. So far I've been using Dom4J for data access, but I'd like to use generated POJO classes. Unfortunately, I receive incomplete code when using hbm2java. The property belonging to the primary key is missing. Have I forgotten something in the mapping file?

Hibernate version:
3rc1
Mapping documents:
Code:
<?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>
        <class name="Test"
                        table="test"
                        node="test">
                <id name="id" column="ID" node="@id" type="long"
                        >
                        <generator class="native"/>
                </id>
        </class>
</hibernate-mapping>

Code generated by hbm2java:
Code:
// default package

import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class Test implements Serializable {

    /** full constructor */
    public Test() {
    }

    public String toString() {
        return new ToStringBuilder(this)
            .toString();
    }

}

Full stack trace of any exception that occurs:
Code:
org.hibernate.PropertyNotFoundException: Could not find a getter for id in class Test
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 mips.genre.dbdb.DatabaseDatabase.getSessionFactory(DatabaseDatabase.java:34)
at mips.genre.dbdb.DatabaseDatabase.addDatabase(DatabaseDatabase.java:89)

Name and version of the database you are using:
not applicable
The generated SQL (show_sql=true):
not applicable
Debug level Hibernate log excerpt:


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.