-->
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.  [ 6 posts ] 
Author Message
 Post subject: Middlegen with genXDocletTags
PostPosted: Tue Dec 16, 2003 7:02 pm 
Newbie

Joined: Tue Dec 09, 2003 8:31 am
Posts: 17
I had been testing out using the following process:

1 - Generate hbm.xml using middlegen
2 - Generate java code using hbm2java

I am using an Oracle database and connecting via jdbc.

Everything was working until I set the value of genXDocletTags to "true".

When I run my test I receive errors that it had trouble reading the hbm.xml files. If I change the value of genXDocletTags back to "false", everything works.

Code:
java.sql.SQLException: Error reading resource: com/invisioninc/data/DtDaypartGroup.hbm.xml
   at com.invisioninc.services.QueryManagerHibernate.inactivateDayPartGroup(QueryManagerHibernate.java:564)
   at com.invisioninc.services.QueryManagerHibernateTest.testUpdateDaypartGroup2(QueryManagerHibernateTest.java:191)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)


Here is the hbm file:
Code:
<?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>
<!--
    Created by Middlegen Hibernate plugin

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.invisioninc.data.DtDaypartGroup"
    table="DT_DAYPART_GROUP"
>
    <meta attribute="field-description">
       @hibernate.class
        table="DT_DAYPART_GROUP"
    </meta>

    <composite-id name="comp_id" class="com.invisioninc.data.DtDaypartGroupPK">
        <meta attribute="field-description">
           @hibernate.id
            generator-class="assigned"
        </meta>
        <key-property
            name="outletCd"
            column="OUTLET_CD"
            type="java.lang.String"
            length="6"
        />
        <key-property
            name="daypartGroupNum"
            column="DAYPART_GROUP_NUM"
            type="short"
            length="4"
        />
    </composite-id>   

    <property
        name="startDate"
        type="java.sql.Timestamp"
        column="START_DATE"
        not-null="true"
        length="7"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="START_DATE"
            length="7"
            not-null="true"
        </meta>   
    </property>
    <property
        name="endDate"
        type="java.sql.Timestamp"
        column="END_DATE"
        length="7"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="END_DATE"
            length="7"
        </meta>   
    </property>
    <property
        name="activeInd"
        type="java.lang.String"
        column="ACTIVE_IND"
        not-null="true"
        length="1"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="ACTIVE_IND"
            length="1"
            not-null="true"
        </meta>   
    </property>
    <property
        name="auditDate"
        type="java.sql.Timestamp"
        column="AUDIT_DATE"
        not-null="true"
        length="7"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="AUDIT_DATE"
            length="7"
            not-null="true"
        </meta>   
    </property>
    <property
        name="auditUser"
        type="int"
        column="AUDIT_USER"
        not-null="true"
        length="6"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="AUDIT_USER"
            length="6"
            not-null="true"
        </meta>   
    </property>

    <!-- associations -->

</class>
</hibernate-mapping>


Anyone know what could be causing this? I am using Middlegen-Hibernate release 3.

Thanks,

Craig


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 7:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I have made a few changes to the XDoclet Mark contained by the meta tags as there are some minor errors. The HBM you supplied looks fine. Can you show the Java classes that was generated please. Also, what version of Hibernate (as 2.1 has the DTD to validate against but the stack trace does not show a validation error).

You could try using this mapping with the HBM generated class previous generated with no XDoclet tags. I am not saying hbm2java is the problem but using a process of elimination the problem should be able to be sorted and I can only see the hbm at this point.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 9:25 am 
Newbie

Joined: Tue Dec 09, 2003 8:31 am
Posts: 17
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 9:31 am 
Newbie

Joined: Tue Dec 09, 2003 8:31 am
Posts: 17
One other thing. I am using Hibernate 2.1 rc1


Top
 Profile  
 
 Post subject: Using 2.1 final fixed problem
PostPosted: Wed Dec 17, 2003 12:41 pm 
Newbie

Joined: Tue Dec 09, 2003 8:31 am
Posts: 17
Not sure why, but I switched over to using Hibernate 2.1 final version and things run fine.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 9:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There have been a few changes here and there hence why we have betas and rc etc. Glad its sorted (at least this far).


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