-->
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.  [ 5 posts ] 
Author Message
 Post subject: SchemaExport generates errors that are not very helpful ...
PostPosted: Wed Sep 08, 2004 5:18 am 
Newbie

Joined: Wed Sep 08, 2004 4:16 am
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 8:12 am 
Newbie

Joined: Wed Sep 08, 2004 4:16 am
Posts: 5
It seems related to the fact that my BaseEntity class includes references to the Person class.

When I switch the updatedBy and createdBy fields in BaseEntity to simple integers it works!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 12:41 pm 
Beginner
Beginner

Joined: Thu Jan 15, 2004 11:16 am
Posts: 37
Did you get an answer to this issue?
I am seeing the same problem when trying to map a simple containment pattern.
It could be that the hibernate xdoclet integration is generating the wrong hbm.xml file content.

I saw something that said that...

<many-to-one name="parent"
type="foo.Value" column="PARENT_ID"/>


you should use:

<many-to-one name="parent"
class="foo.Value" column="PARENT_ID"/>


So it should be class instead of type.
Not great hibernate error reporting.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 4:48 am 
Newbie

Joined: Wed Sep 08, 2004 4:16 am
Posts: 5
Thanks!

Your reply is the first and it sounds like a correct guess that the problem is related to XDocLet.

I wonder if my XDocLet tags are wrong and/or if there is a way around the problem except for ditching XDocLet.

For now on I'm living with the fact that my <createdBy> and <updatedby> properties are plain integers.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 13, 2007 5:14 am 
Newbie

Joined: Wed May 17, 2006 12:25 pm
Posts: 2
Some other: http://forum.hibernate.org/viewtopic.php?t=936154

My experience: that could be mean, that the class is not found.


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