-->
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.  [ 2 posts ] 
Author Message
 Post subject: Joined Subclass Mapping issue
PostPosted: Wed Sep 07, 2005 6:12 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
The artifact generation is failing on Invoice.hbm.xml, where it's failing is a complete mystery to me as I was using a similar mapping with no problems the other day. I'm sure there's an obvious mistake somewhere but this could really do with a fresh pair of eyes. Also, does anyone know how to get more error information from the artifcat generation tool.

A little bit more background information. When an invoice is paid it becomes a paid invoice with a paid date. If an invoice is only part paid it is reissued and a letter is appended to its invoice number and it now has a parent invoice.


Hibernate version:
3.05

Mapping documents:
hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <property name="connection.driver_class">
         org.hsqldb.jdbcDriver
      </property>
      <property name="connection.url">
         jdbc:hsqldb:hsql://localhost/
      </property>
      <property name="connection.username">sa</property>
      <property name="dialect">
         org.hibernate.dialect.HSQLDialect
      </property>
      <property name="hbm2ddl.auto">create</property>
      <property name="jdbc.batch_size">50</property>
      <property name="show_sql">true</property>
      <property name="use_sql_comments">true</property>
      <property name="query.substitutions">true</property>
      <property name="c3p0.max_size">5</property>
      <property name="c3p0.min_size">1</property>
      <property name="c3p0.timeout">5000</property>
      <property name="c3p0.max_statements">100</property>
      <property name="c3p0.idle_test_period">3000</property>
      <property name="c3p0.acquire_increment">1</property>
      <property name="c3p0.validate">true</property>
      <mapping resource="Customer.hbm.xml" />
      <mapping resource="Ledger.hbm.xml" />
      <mapping resource="Group.hbm.xml" />
      <mapping resource="Site.hbm.xml" />
      <mapping resource="Invoice.hbm.xml" />
   </session-factory>
</hibernate-configuration>

Customer.hbm.xml
Code:
<?xml version="1.0"?>
<!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.npower.invoiceauditor.model.Customer">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <generator class="hilo" />
      </id>
      <property name="customerName" type="java.lang.String"
         unique="true" not-null="true" length="128" />
      <property name="paymentTerms" type="java.lang.Integer"/>
      <set name="ledgers" inverse="true" cascade="all">
         <key column="customer"/>
         <one-to-many class="com.npower.invoiceauditor.model.Ledger" />
      </set>
   </class>
</hibernate-mapping>

Ledger.hbm.xml
Code:
<?xml version="1.0"?>
<!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.npower.invoiceauditor.model.Ledger">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <generator class="hilo" />
      </id>
      <property name="ledgerNumber" type="int" />
      <many-to-one name="customer"
         class="com.npower.invoiceauditor.model.Customer" />
      <set name="groups" cascade="all" inverse="true">
         <key column="ledger"/>
         <one-to-many class="com.npower.invoiceauditor.model.Group" />
      </set>
   </class>
</hibernate-mapping>
Group.hbm.xml
Code:
<?xml version="1.0"?>
<!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.npower.invoiceauditor.model.Group" table="GROUPOFSITES">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <generator class="hilo" />
      </id>
      <property name="groupNumber" type="java.lang.String"
         not-null="true" unique="false" length="4" />
      <many-to-one name="ledger"
         class="com.npower.invoiceauditor.model.Ledger" />
      <set name="sites" cascade="all" inverse="true" order-by="accountnumber desc">
         <key column="parentGroup"/>
         <one-to-many class="com.npower.invoiceauditor.model.Site" />
      </set>
   </class>
</hibernate-mapping>
Site.hbm.xml
Code:
<?xml version="1.0"?>
<!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.npower.invoiceauditor.model.Site">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <generator class="hilo" />
      </id>
      
      <property name="accountNumber" type="java.lang.String"
         unique="false" not-null="true" length="8" />
      <many-to-one name="parentGroup"
         class="com.npower.invoiceauditor.model.Group" />
      <set name="unpaidInvoices" cascade="all" inverse="true">
         <key column="site"/>
         <one-to-many class="com.npower.invoiceauditor.model.UnpaidInvoice" />
      </set>
      <set name="paidInvoices" cascade="all" inverse="true">
         <key column="site"/>
         <one-to-many class="com.npower.invoiceauditor.model.PaidInvoice" />         
      </set>
   </class>
</hibernate-mapping>

Invoice.hbm.xml
Code:
<?xml version="1.0"?>
<!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.npower.invoiceauditor.model.Invoice">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <generator class="hilo" />
      </id>

      <property name="invoiceNumber" type="java.lang.String"
         unique="false" not-null="true" length="10" />
      <property name="paid" type="java.lang.Boolean" not-null="true" />
      <property name="value" type="java.math.BigDecimal"
         not-null="true" />
      <property name="dateDue" type="java.util.Date" not-null="true" />

      <joined-subclass
         name="com.npower.invoiceauditor.model.UnpaidInvoice">
         <key column="invoice" />
         <many-to-one name="site" />
      </joined-subclass>

      <joined-subclass
         name="com.npower.invoiceauditor.model.PaidInvoice" ">
         <key column="invoice" />
         <property name="datePaid" type="java.util.Date"
            not-null="true" />

         <many-to-one name="site" />

         <set name="paidReissues" cascade="all" inverse="true">
            <key column="paidParent" />
            <one-to-many
               class="com.npower.invoiceauditor.model.PaidReissue" />
         </set>
         <set name="unpaidReissues" cascade="all" inverse="true">
            <key column="unpaidParent" />
            <one-to-many
               class="com.npower.invoiceauditor.model.UnpaidReissue" />
         </set>
      </joined-subclass>


      <joined-subclass
         name="com.npower.invoiceauditor.model.PaidReissue">
         <key column="invoice" />
         <property name="datePaid" type="java.util.Date"
            not-null="true" />
         <many-to-one name="paidParent"
            class="com.npower.invoiceauditor.model.PaidInvoice" />
      </joined-subclass>

      <joined-subclass
         name="com.npower.invoiceauditor.model.UnpaidReissue">
         <key column="invoice" />
         <many-to-one name="unpaidParent"
            class="com.npower.invoiceauditor.model.PaidInvoice" />
      </joined-subclass>

   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 6:47 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
I think I've managed to isolate the problem a little bit more. Providing there is not a <many-to-one> in the joined-subclass everything works fine. However, this confuses me as this was working with this mapping.

Code:
<?xml version="1.0"?>
<!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.npower.mds.audit.model.Invoice">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <generator class="hilo" />
      </id>
      <property name="paid" type="java.lang.Boolean" not-null="true" />
      <property name="invoiceNumber" type="java.lang.String"
         unique="false" not-null="true" length="10" />
      <property name="value" type="java.math.BigDecimal"
         not-null="true" />
      <property name="date" type="java.util.Date" not-null="true" />
      

      <joined-subclass
         name="com.npower.mds.audit.model.UnpaidInvoice">
         <key column="invoice" />
         <many-to-one name="site" />
      </joined-subclass>

      <joined-subclass
         name="com.npower.mds.audit.model.PaidInvoice">
         <key column="invoice" />
         <many-to-one name="site" />
         <property name="paidDate" type="java.util.Date"
            not-null="false" />
         <set name="reissues" cascade="all" inverse="true">
            <key column="parent" />
            <one-to-many class="com.npower.mds.audit.model.ReIssue" />
         </set>
      </joined-subclass>

      <joined-subclass name="com.npower.mds.audit.model.ReIssue">
      <key column="invoice" />
      <many-to-one name="parent" />
      <property name="paidDate" type="java.util.Date"
            not-null="false" />
      </joined-subclass>

   </class>
</hibernate-mapping>


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