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: