Hi!
I'm relative new to Hibernate but quite an experienced java developer :)-
My problem is that SchemaExport goes wrong and the error messages are not very helpful. Se stacktrace below ...
I have just two simple classes where one of them is an abstract base class that I intend to use for all my entity classes. Se code below.
Thanks in advance!
Hibernate version:
2.1.6
Name and version of the database you are using:
MySQL 4.0.20a-nt
XDoclet version:
1.2
Full stack trace of any exception that occurs:
Buildfile: C:\dev\workspace\utskicket\build.xml
init:
compile:
[javac] Compiling 2 source files to C:\dev\workspace\utskicket\build
hibernate:
[hibernatedoclet] (XDocletMain.start 47 ) Running <hibernate/>
[hibernatedoclet] Generating mapping file for utskicket.db.Person.
[hibernatedoclet] utskicket.db.Person
schema:
[schemaexport] 10:41:14,625 INFO net.sf.hibernate.cfg.Environment - Hibernate 2.1.6
[schemaexport] 10:41:14,625 INFO net.sf.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql:///utskicket, hibernate.show_sql=true, hibernate.connection.password=, hibernate.connection.pool_size=1}
[schemaexport] 10:41:14,640 INFO net.sf.hibernate.cfg.Environment - using java.io streams to persist binary types
[schemaexport] 10:41:14,640 INFO net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
[schemaexport] 10:41:14,640 INFO net.sf.hibernate.cfg.Configuration - configuring from file: hibernate.cfg.xml
[schemaexport] 10:41:14,812 INFO net.sf.hibernate.cfg.Configuration - Mapping resource: utskicket/db/Person.hbm.xml
[schemaexport] 10:41:14,921 INFO net.sf.hibernate.cfg.Binder - Mapping class: utskicket.db.Person -> persons
[schemaexport] 10:41:15,015 ERROR net.sf.hibernate.cfg.Configuration - Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: Could not interpret type: utskicket.db.Person
[schemaexport] at net.sf.hibernate.cfg.Binder.getTypeFromXML(Binder.java:934)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindSimpleValue(Binder.java:435)
[schemaexport] at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1047)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:362)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
[schemaexport] at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
[schemaexport] at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
[schemaexport] at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:931)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:186)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:301)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:377)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)
BUILD FAILED: C:\dev\workspace\utskicket\build.xml:121: Schema text failed: Error reading resource: utskicket/db/Person.hbm.xml
Total time: 5 seconds
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="utskicket.db.Person"
table="persons"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="ID"
column="id"
type="java.lang.Integer"
>
<generator class="native">
</generator>
</id>
<property
name="firstName"
type="java.lang.String"
update="true"
insert="true"
column="firstname"
/>
<property
name="lastName"
type="java.lang.String"
update="true"
insert="true"
column="lastname"
/>
<property
name="email"
type="java.lang.String"
update="true"
insert="true"
column="email"
/>
<property
name="created"
type="java.util.Date"
update="true"
insert="true"
column="created"
/>
<property
name="updated"
type="java.util.Date"
update="true"
insert="true"
column="updated"
/>
<property
name="createdBy"
type="utskicket.db.Person"
update="true"
insert="true"
column="createdBy"
/>
<property
name="updatedBy"
type="utskicket.db.Person"
update="true"
insert="true"
column="updatedBy"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Person.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
The base class:
Code:
/*
* Fil: BaseEntity.java
*
* Date When What
* ===== === ===
* 2004-09-06 Gunnar File created.
*/
package utskicket.db;
import java.util.Date;
/**
* Base class for all our entity classes.
*
* @author Gunnar
* ------------------------------
*/
public abstract class BaseEntity {
private Integer ID;
private Date created;
private Date updated;
private Person createdBy;
private Person updatedBy;
/** */
public BaseEntity() {
}
/**
* The unique ID for the entity.
*
* @return The id.
* ----------------------------------------------------
* @hibernate.id
* generator-class="native"
* column="id"
*/
public Integer getID() {
return ID;
}
private void setID(Integer pID) {
ID = pID;
}
/**
* @return Creation time.
* ----------------------------------------------------
* @hibernate.property
* column="created"
*/
public Date getCreated() {
return created;
}
public void setCreated(Date pTime) {
created = pTime;
}
/**
* @return Update time.
* ----------------------------------------------------
* @hibernate.property
* column="updated"
*/
public Date getUpdated() {
return updated;
}
public void setUpdated(Date pTime) {
updated = pTime;
}
/**
* @return The person who created the enity.
* ----------------------------------------------------
* @hibernate.property
* column="createdBy"
*/
public Person getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Person pPerson) {
createdBy = pPerson;
}
/**
* @return The person who updated the enity.
* ----------------------------------------------------
* @hibernate.property
* column="updatedBy"
*/
public Person getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(Person pPerson) {
updatedBy = pPerson;
}
}
The entity class:[code]
/*
* Person.java
*
* Date Who What
* ===== === ===
* 2004-09-07 Gunnar Created file.
*/
package utskicket.db;
/**
* A person using the system.
*
* @author Gunnar
* ------------------------------
* @hibernate.class
* table="persons"
*/
public class Person extends BaseEntity {
private String firstName;
private String lastName;
private String email;
/**
* F