-->
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.  [ 4 posts ] 
Author Message
 Post subject: table fails to be created by ant task
PostPosted: Wed Jul 12, 2006 9:54 pm 
Beginner
Beginner

Joined: Sat Jul 08, 2006 2:58 pm
Posts: 26
I have edited my POJOs and added Xdoclet tags to generate my .hbm.xml mapping files. My ant task is able to generate all my .hbm.xml files and my hibernate.cfg.xml file also. Everything seems to work ok until I try to create my database files.

My ant task to create the tables is:

Code:
<!-- =================================
          target: schema-recreate             
         ================================= -->
   <target name="schema-recreate"  depends="compile, schema-drop" description="Recreates (with drop) the schema on the server.">
      <echo>  Schema recreate </echo>
      <hibernatetool destdir="${deploy}">
         <classpath refid="project.classpath" />
         <configuration configurationfile="${classes}/hibernate.cfg.xml" />
         <hbm2ddl drop="false" create="true" export="true" update="false" />
      </hibernatetool>
   </target>


What happens is that all of my tables get generated except for one. But I don't see a problem with my mapping file.

This is the code for the POJO that fails:

Code:
package com.chisq.common.bo;


/** @author Hibernate CodeGenerator */
/**
  * @hibernate.class
  * table="Familyhistory"
  */
public class Familyhistory extends BaseObject {
   
   private static final long serialVersionUID=0;

    private Long id;
    private Person person;
    private String personName;
    private Pickpersonrelationship relationship;
    private String condition;
    private Integer ageAtDeath;
    private String causeOfDeath;

    /** full constructor */
    public Familyhistory( Long id, Person person, String personName,
                          Pickpersonrelationship relationship, String condition,
                          Integer ageAtDeath, String causeOfDeath) {
        this.id = id;
        this.person = person;
        this.personName = personName;
        this.relationship = relationship;
        this.condition = condition;
        this.ageAtDeath = ageAtDeath;
        this.causeOfDeath = causeOfDeath;
    }

    /** default constructor */
    public Familyhistory() {
    }

    /** minimal constructor */
    public Familyhistory(Long id, Person person) {
        this.id = id;
        this.person = person;
    }

    /**
      * @hibernate.id
      * column="FamilyhistoryID"
      * generator-class="native"
      */
   public Long getId() {
      return id;
   }
   public void setId(Long id) {
      this.id = id;
   }

    /**
      * @hibernate.many-to-one
      * column="personID"
      * not-null="true"
      */
    public Person getPerson() {
        return this.person;
    }
    public void setPerson(Person person) {
        this.person = person;
    }

    /**
      * @hibernate.property
      * column="personName"
      */
    public String getPersonName() {
        return this.personName;
    }
    public void setPersonName(String personName) {
        this.personName = personName;
    }

    /**
      * @hibernate.many-to-one
      * column="relationshipID"
      * not-null="true"
      */
    public Pickpersonrelationship getRelationship() {
        return this.relationship;
    }
    public void setRelationship(Pickpersonrelationship relationship) {
        this.relationship = relationship;
    }

    /**
      * @hibernate.property
      * column="condition"
      */
    public String getCondition() {
        return this.condition;
    }
    public void setCondition(String condition) {
        this.condition = condition;
    }

    /**
      * @hibernate.property
      * column="ageAtDeath"
      */
    public Integer getAgeAtDeath() {
        return this.ageAtDeath;
    }
    public void setAgeAtDeath(Integer ageAtDeath) {
        this.ageAtDeath = ageAtDeath;
    }

    /**
      * @hibernate.property
      * column="causeOfDeath"
      */
    public String getCauseOfDeath() {
        return this.causeOfDeath;
    }
    public void setCauseOfDeath(String causeOfDeath) {
        this.causeOfDeath = causeOfDeath;
    }
}


The mapping file that gets generated by my ant task looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
    <class
        name="com.chisq.common.bo.Familyhistory"
        table="Familyhistory"
    >

        <id
            name="id"
            column="familyhistoryID"
            type="java.lang.Long"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Familyhistory.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <many-to-one
            name="person"
            class="com.chisq.common.bo.Person"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="personID"
            not-null="true"
        />

        <property
            name="personName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="personName"
        />

        <many-to-one
            name="relationship"
            class="com.chisq.common.bo.Pickpersonrelationship"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="relationshipID"
            not-null="true"
        />

        <property
            name="condition"
            type="java.lang.String"
            update="true"
            insert="true"
            column="condition"
        />

        <property
            name="ageAtDeath"
            type="java.lang.Integer"
            update="true"
            insert="true"
            column="ageAtDeath"
        />

        <property
            name="causeOfDeath"
            type="java.lang.String"
            update="true"
            insert="true"
            column="causeOfDeath"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Familyhistory.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>



These are the errors I get:


Code:
[hibernatetool] create table Familyhistory (familyhistoryID bigint not null auto_increment, personID bigint not null, personName varchar(255), relationshipID bigint not null, condition varchar(255), ageAtDeath integer, causeOfDeath varchar(255), primary key (familyhistoryID));
[hibernatetool] (hbm2ddl.SchemaExport                272 ) Unsuccessful: create table Familyhistory (familyhistoryID bigint not null auto_increment, personID bigint not null, personName varchar(255), relationshipID bigint not null, condition varchar(255), ageAtDeath integer, causeOfDeath varchar(255), primary key (familyhistoryID))
[hibernatetool] (hbm2ddl.SchemaExport                273 ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition varchar(255), ageAtDeath integer, causeOfDeath varchar(255), primary k' at line 1


Since I use the tools to generate the SQL to create the table what might I be doing to cause the error?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 2:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
check the generated sql and see what is wrong with it. Maybe you are using a MySQL reserved word ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 9:26 am 
Beginner
Beginner

Joined: Sat Jul 08, 2006 2:58 pm
Posts: 26
How do I check the generated SQL? Does it get written to a file somewhere?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 9:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you enable logging it will and hbm2ddl also have an option to store the output in a file. check the dcos.

_________________
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.  [ 4 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.