Here is the java that was generated :
Code:
package com.invisioninc.data;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class DtDaypartGroup implements Serializable {
/** identifier field */
private com.invisioninc.data.DtDaypartGroupPK comp_id;
/** persistent field */
private Date startDate;
/** nullable persistent field */
private Date endDate;
/** persistent field */
private String activeInd;
/** persistent field */
private Date auditDate;
/** persistent field */
private int auditUser;
/** full constructor */
public DtDaypartGroup(com.invisioninc.data.DtDaypartGroupPK comp_id, Date startDate, Date endDate, String activeInd, Date auditDate, int auditUser) {
this.comp_id = comp_id;
this.startDate = startDate;
this.endDate = endDate;
this.activeInd = activeInd;
this.auditDate = auditDate;
this.auditUser = auditUser;
}
/** default constructor */
public DtDaypartGroup() {
}
/** minimal constructor */
public DtDaypartGroup(com.invisioninc.data.DtDaypartGroupPK comp_id, Date startDate, String activeInd, Date auditDate, int auditUser) {
this.comp_id = comp_id;
this.startDate = startDate;
this.activeInd = activeInd;
this.auditDate = auditDate;
this.auditUser = auditUser;
}
/**
* @hibernate.id
* generator-class="assigned"
*
*/
public com.invisioninc.data.DtDaypartGroupPK getComp_id() {
return this.comp_id;
}
public void setComp_id(com.invisioninc.data.DtDaypartGroupPK comp_id) {
this.comp_id = comp_id;
}
/**
* @hibernate.property
* column="START_DATE"
* length="7"
* not-null="true"
*
*/
public Date getStartDate() {
return this.startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
/**
* @hibernate.property
* column="END_DATE"
* length="7"
*
*/
public Date getEndDate() {
return this.endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
/**
* @hibernate.property
* column="ACTIVE_IND"
* length="1"
* not-null="true"
*
*/
public String getActiveInd() {
return this.activeInd;
}
public void setActiveInd(String activeInd) {
this.activeInd = activeInd;
}
/**
* @hibernate.property
* column="AUDIT_DATE"
* length="7"
* not-null="true"
*
*/
public Date getAuditDate() {
return this.auditDate;
}
public void setAuditDate(Date auditDate) {
this.auditDate = auditDate;
}
/**
* @hibernate.property
* column="AUDIT_USER"
* length="6"
* not-null="true"
*
*/
public int getAuditUser() {
return this.auditUser;
}
public void setAuditUser(int auditUser) {
this.auditUser = auditUser;
}
public String toString() {
return new ToStringBuilder(this)
.append("comp_id", getComp_id())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof DtDaypartGroup) ) return false;
DtDaypartGroup castOther = (DtDaypartGroup) other;
return new EqualsBuilder()
.append(this.getComp_id(), castOther.getComp_id())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getComp_id())
.toHashCode();
}
}
The only reason I started generating the hbm with the xdoclet tags is that the next step in my build process is to compile all the code and then use hibernatedoclet to generate a sar for JBoss. With my current ant target I am creating the jboss-service.xml and their is a subtask that creates the hbm files from the java source. Obvioulsy this is redundant since I already have the hbm files that were generated from middlegen. If there is a way that I can use the hibernatedoclet task and have it use the hbm files previoulsly generated with middlegen, then I would not need to genrate the xdoclet tags in the middlgen task.
Here is my hibernatedoclet target:
Code:
<target name="generate-Hibernate"
description="Generates Hibernate class descriptor files and jboss-service.xml"
depends="compile">
<!-- copy additional resources for the Hibernate XDoclet task to the mergedir -->
<mkdir dir="${build.dir}/sar/hibernate"/>
<!-- copy todir="${build.dir}/sar/hibernate">
<fileset dir="${src.dir}">
<include name="**/hibernate/hibernate-properties-*.xml"/>
</fileset>
<fileset dir="${basedir}/config/sar/hibernate">
<include name="jboss-service-custom.xml"/>
</fileset>
</copy -->
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask">
<classpath>
<path refid="xdoclet.path"/>
<fileset dir="${xdoclet.home}/lib" includes="*.jar"/>
</classpath>
</taskdef>
<!-- Execute the hibernatedoclet task -->
<hibernatedoclet
destdir="${build.dir}/sar/hibernate"
excludedtags="@version,@author,@todo,@see,@desc"
addedtags="@xdoclet-generated at ${TODAY}@copyright yourCompany,@author yourCompany,@version ${version}"
force="${xdoclet.force}"
mergedir="${build.dir}/sar/hibernate"
verbose="false">
<fileset dir="${build.generate.dir}">
<include name="**/data/*.java"/>
</fileset>
<!-- The hibernate subtask is used to generate the hbm files. We did that with middlegen -->
<hibernate version="2.0" />
<jbossservice
destdir="${build.dir}/sar/hibernate"
serviceName="Hibernate"
jndiName="${hibernate.jndi.name}"
dataSource="${hibernate.datasource.name}"
dialect="${hibernate.dialect}"
useOuterJoin="true"
transactionManagerStrategy="net.sf.hibernate.transaction.JBossTransactionManagerLookup"
transactionStrategy="net.sf.hibernate.transaction.JTATransactionFactory"
userTransactionName="UserTransaction"
/>
</hibernatedoclet>
</target>
Thanks,
Craig