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.