-->
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.  [ 7 posts ] 
Author Message
 Post subject: Joined subclasses - "Too many tables" with MySQL
PostPosted: Wed May 17, 2006 12:03 pm 
Newbie

Joined: Fri Sep 16, 2005 8:05 am
Posts: 7
Hi all,

I'm getting a curious exception whilst trying to lazy load an object. The exception (full details below) is

org.hibernate.exception.GenericJDBCException: could not load an entity: [org.psygrid.data.model.hibernate.Persistent#591]
...
Caused by: java.sql.SQLException: Too many tables; MySQL can only use 61 tables in a join

Now the way I have the classes set up they all extend a base class Persistent which just takes care of id and version. All other classes extend from this and in the mapping I use joined-subclass, class per table.

Looking at the stack trace it seems that whilst trying to lazy-load a Status object the SQL generated involves joins across virtually all of the tables. As I have more than 61 classes (tables) this apparently goes over MySQL limit of "61 tables in a join". Also, this problem has just manifested itself since I added 5 more classes; before this everything was fine.

I really can't understand why it is trying to execute the SQL shown below - any ideas?

cheers, Rob

Hibernate version: 3.1.2

Mapping documents:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class table="t_persistents" name="org.psygrid.data.model.hibernate.Persistent">
    <id name="id" column="c_id">
      <generator class="native"/>
    </id>
    <version unsaved-value="undefined" name="version" column="c_version"/>
    <joined-subclass name="org.psygrid.data.model.hibernate.BinaryData" table="t_binary_data">
      <key column="c_id"/>
      <property name="blobData" length="2000000" column="c_data"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.BinaryObject" table="t_binary_objects">
      <key column="c_id"/>
      <many-to-one unique="true" column="c_data_id" cascade="all" class="org.psygrid.data.model.hibernate.BinaryData" not-null="false" name="data"/>
      <property name="description" column="c_description"/>
      <property name="fileName" column="c_file_name"/>
      <property name="mimeType" column="c_mime_type"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Component" table="t_components">
      <key column="c_id"/>
      <property name="name" column="c_name"/>
      <property name="description" length="4000" column="c_description" type="text"/>
      <property name="displayText" length="4000" column="c_display_text" type="text"/>
      <joined-subclass name="org.psygrid.data.model.hibernate.DocumentGroup" table="t_doc_groups">
        <key column="c_id"/>
        <property name="label" column="c_label"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.DocumentOccurrence" table="t_doc_occs">
        <key column="c_id"/>
        <property name="label" column="c_label"/>
        <many-to-one insert="false" column="c_doc_id" update="false" class="org.psygrid.data.model.hibernate.Document" not-null="true" name="document"/>
        <many-to-one column="c_doc_grp_id" cascade="none" class="org.psygrid.data.model.hibernate.DocumentGroup" not-null="false" name="documentGroup"/>
        <property name="scheduleTime" column="c_time"/>
        <property name="enumUnits" column="c_units"/>
        <list cascade="all" name="reminders">
          <key not-null="true" column="c_schedulable_id"/>
          <list-index column="c_index"/>
          <one-to-many class="org.psygrid.data.model.hibernate.Reminder"/>
        </list>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.Element" table="t_elements">
        <key column="c_id"/>
        <many-to-one column="c_dataset_id" class="org.psygrid.data.model.hibernate.DataSet" not-null="false" name="myDataSet"/>
        <joined-subclass name="org.psygrid.data.model.hibernate.Entry" table="t_entrys">
          <key column="c_id"/>
          <property name="label" column="c_label"/>
          <many-to-one column="c_section_id" cascade="none" class="org.psygrid.data.model.hibernate.Section" not-null="false" name="section"/>
          <property name="enumEntryStatus" column="c_entry_status"/>
          <joined-subclass name="org.psygrid.data.model.hibernate.BasicEntry" table="t_basic_entrys">
            <key column="c_id"/>
            <list cascade="save-update" table="t_entry_rules" name="validationRules">
              <key column="c_entry_id"/>
              <list-index column="c_index"/>
              <many-to-many class="org.psygrid.data.model.hibernate.ValidationRule" column="c_rule_id"/>
            </list>
            <list cascade="save-update" table="t_entry_transformers" name="transformers">
              <key column="c_entry_id"/>
              <list-index column="c_index"/>
              <many-to-many class="org.psygrid.data.model.hibernate.Transformer" column="c_transformer_id"/>
            </list>
            <list cascade="none" table="t_entry_units" name="units">
              <key column="c_entry_id"/>
              <list-index column="c_index"/>
              <many-to-many class="org.psygrid.data.model.hibernate.Unit" column="c_unit_id"/>
            </list>
            <joined-subclass name="org.psygrid.data.model.hibernate.BooleanEntry" table="t_boolean_entrys">
              <key column="c_id"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.DateEntry" table="t_date_entrys">
              <key column="c_id"/>
              <property name="format" column="c_format"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.DerivedEntry" table="t_derived_entrys">
              <key column="c_id"/>
              <property name="formula" length="4000" column="c_formula" type="text"/>
              <map cascade="all-delete-orphan" table="t_variables" name="variables">
                <key column="c_entry_id"/>
                <map-key type="string" column="c_variable_name"/>
                <many-to-many class="org.psygrid.data.model.hibernate.BasicEntry" column="c_input_id"/>
              </map>
              <property name="aggregateOperator" length="3" column="c_agg_opertr"/>
              <many-to-one unique="false" column="c_composite_id" cascade="none" class="org.psygrid.data.model.hibernate.CompositeEntry" not-null="false" name="composite"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.IntegerEntry" table="t_integer_entrys">
              <key column="c_id"/>
              <property name="defaultValue" column="c_default"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.LongTextEntry" table="t_long_text_entrys">
              <key column="c_id"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.NumericEntry" table="t_numeric_entrys">
              <key column="c_id"/>
              <property name="defaultValue" column="c_default"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.OptionEntry" table="t_option_entrys">
              <key column="c_id"/>
              <many-to-one unique="true" column="c_default_id" class="org.psygrid.data.model.hibernate.Option" not-null="false" name="defaultValue"/>
              <list cascade="all" name="options">
                <key not-null="true" column="c_entry_id"/>
                <list-index column="c_index"/>
                <one-to-many class="org.psygrid.data.model.hibernate.Option"/>
              </list>
              <property name="optionCodesDisplayed" column="c_disp_codes"/>
            </joined-subclass>
            <joined-subclass name="org.psygrid.data.model.hibernate.TextEntry" table="t_text_entrys">
              <key column="c_id"/>
              <property name="size" column="c_text_size"/>
            </joined-subclass>
          </joined-subclass>
          <joined-subclass name="org.psygrid.data.model.hibernate.CompositeEntry" table="t_comp_entrys">
            <key column="c_id"/>
            <list cascade="all" table="t_row_labels" name="rowLabels">
              <key column="c_comp_id"/>
              <list-index column="c_index"/>
              <element not-null="true" type="string" column="c_row_label"/>
            </list>
            <list cascade="all" name="entries">
              <key not-null="false" column="c_comp_ent_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.BasicEntry"/>
            </list>
          </joined-subclass>
          <joined-subclass name="org.psygrid.data.model.hibernate.NarrativeEntry" table="t_narrative_entrys">
            <key column="c_id"/>
            <property name="enumStyle" column="c_style"/>
          </joined-subclass>
        </joined-subclass>
        <joined-subclass name="org.psygrid.data.model.hibernate.StatusedElement" table="t_statused_elements">
          <key column="c_id"/>
          <list cascade="all-delete-orphan" name="statuses">
            <key not-null="true" column="c_element_id"/>
            <list-index column="c_index"/>
            <one-to-many class="org.psygrid.data.model.hibernate.Status"/>
          </list>
          <joined-subclass name="org.psygrid.data.model.hibernate.DataSet" proxy="org.psygrid.data.model.hibernate.DataSet" table="t_datasets">
            <key column="c_id"/>
            <property name="versionNo" column="c_version"/>
            <property name="published" column="c_published" not-null="true"/>
            <many-to-one column="c_e_doc" cascade="all" class="org.psygrid.data.model.hibernate.BinaryObject" not-null="false" name="info"/>
            <property name="dateModified" column="c_date_modified"/>
            <list cascade="all" name="allConsentFormGroups">
              <key not-null="true" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.ConsentFormGroup"/>
            </list>
            <list cascade="all-delete-orphan" name="validationRules">
              <key not-null="false" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.ValidationRule"/>
            </list>
            <property name="idSuffixSize" column="c_suffix_size"/>
            <list cascade="all" name="transformers">
              <key not-null="true" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.Transformer"/>
            </list>
            <list cascade="all" name="documentGroups">
              <key not-null="true" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.DocumentGroup"/>
            </list>
            <list cascade="all" name="units">
              <key not-null="true" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.Unit"/>
            </list>
            <property name="projectCode" column="c_project_code" unique="true" not-null="true"/>
            <property name="scheduleStartQuestion" column="c_sch_st_qu"/>
            <list cascade="all" name="documents">
              <key not-null="true" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.Document"/>
            </list>
            <list cascade="all" name="groups">
              <key not-null="true" column="c_dataset_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.Group"/>
            </list>
          </joined-subclass>
          <joined-subclass name="org.psygrid.data.model.hibernate.Document" table="t_documents">
            <key column="c_id"/>
            <list cascade="all" name="entries">
              <key not-null="false" column="c_document_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.Entry"/>
            </list>
            <list cascade="all" name="sections">
              <key not-null="false" column="c_document_id"/>
              <list-index column="c_index"/>
              <one-to-many class="org.psygrid.data.model.hibernate.Section"/>
            </list>
            <list cascade="none" table="t_doc_cfgs" name="conFrmGrps">
              <key column="c_doc_id"/>
              <list-index column="c_index"/>
              <many-to-many class="org.psygrid.data.model.hibernate.ConsentFormGroup" column="c_cfg_id"/>
            </list>
            <list cascade="all" name="occurrences">
              <key not-null="true" column="c_doc_id"/>
              <list-index column="c_index_doc"/>
              <one-to-many class="org.psygrid.data.model.hibernate.DocumentOccurrence"/>
            </list>
          </joined-subclass>
        </joined-subclass>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.Option" table="t_options">
        <key column="c_id"/>
        <property name="code" column="c_code" not-null="false"/>
        <property name="textEntryAllowed" column="c_text_allowed"/>
        <list cascade="all" name="optionDependents">
          <key not-null="true" column="c_option_id"/>
          <list-index column="c_index"/>
          <one-to-many class="org.psygrid.data.model.hibernate.OptionDependent"/>
        </list>
        <many-to-one insert="false" column="c_entry_id" update="false" class="org.psygrid.data.model.hibernate.OptionEntry" not-null="true" name="entry"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.Section" table="t_sections">
        <key column="c_id"/>
        <list cascade="all" name="occurrences">
          <key not-null="true" column="c_section_id"/>
          <list-index column="c_index"/>
          <one-to-many class="org.psygrid.data.model.hibernate.SectionOccurrence"/>
        </list>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.SectionOccurrence" table="t_sec_occs">
        <key column="c_id"/>
        <property name="label" column="c_label"/>
        <many-to-one insert="false" column="c_section_id" update="false" class="org.psygrid.data.model.hibernate.Section" not-null="true" name="section"/>
        <property name="enumEntryStatus" column="c_entry_status"/>
        <property name="multipleAllowed" column="c_multiple_allowed"/>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Consent" table="t_consents">
      <key column="c_id"/>
      <many-to-one column="c_e_doc" class="org.psygrid.data.model.hibernate.BinaryObject" not-null="false" name="consentDoc"/>
      <property name="consentGiven" column="c_consent_given"/>
      <property name="location" column="c_location"/>
      <many-to-one column="c_cons_form_id" class="org.psygrid.data.model.hibernate.ConsentForm" not-null="false" name="consentForm"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.ConsentForm" table="t_consent_forms">
      <key column="c_id"/>
      <many-to-one column="c_e_doc" cascade="all" class="org.psygrid.data.model.hibernate.BinaryObject" not-null="false" name="elecDoc"/>
      <property name="question" column="c_question"/>
      <property name="referenceNumber" column="c_ref_no"/>
      <joined-subclass name="org.psygrid.data.model.hibernate.AssociatedConsentForm" table="t_assoc_con_forms">
        <key column="c_id"/>
        <many-to-one insert="false" column="c_cf_id" update="false" class="org.psygrid.data.model.hibernate.PrimaryConsentForm" not-null="true" name="primaryConsentForm"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.PrimaryConsentForm" table="t_prim_consent_forms">
        <key column="c_id"/>
        <list cascade="all" name="associatedConsentForms">
          <key not-null="true" column="c_cf_id"/>
          <list-index column="c_index"/>
          <one-to-many class="org.psygrid.data.model.hibernate.AssociatedConsentForm"/>
        </list>
        <many-to-one insert="false" column="c_group_id" update="false" class="org.psygrid.data.model.hibernate.ConsentFormGroup" not-null="true" name="group"/>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.ConsentFormGroup" table="t_cons_form_groups">
      <key column="c_id"/>
      <property name="description" column="c_description"/>
      <list cascade="all" name="consentForms">
        <key not-null="true" column="c_group_id"/>
        <list-index column="c_index"/>
        <one-to-many class="org.psygrid.data.model.hibernate.PrimaryConsentForm"/>
      </list>
      <many-to-one insert="false" column="c_dataset_id" update="false" class="org.psygrid.data.model.hibernate.DataSet" not-null="true" name="dataSet"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.ElementInstance" table="t_elem_insts">
      <key column="c_id"/>
      <many-to-one column="c_record_id" class="org.psygrid.data.model.hibernate.Record" not-null="false" name="record"/>
      <list cascade="all" name="provItems">
        <key not-null="false" column="c_response_id"/>
        <list-index column="c_index"/>
        <one-to-many class="org.psygrid.data.model.hibernate.Provenance"/>
      </list>
      <joined-subclass name="org.psygrid.data.model.hibernate.CompositeRow" table="t_comp_rows">
        <key column="c_id"/>
        <set cascade="all" name="basicResponses">
          <key not-null="false" column="c_comp_resp_id"/>
          <one-to-many class="org.psygrid.data.model.hibernate.BasicResponse"/>
        </set>
        <many-to-one insert="false" column="c_comp_resp_id" update="false" class="org.psygrid.data.model.hibernate.CompositeResponse" not-null="false" name="compositeResponse"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.Response" table="t_responses">
        <key column="c_id"/>
        <many-to-one column="c_entry_id" cascade="none" class="org.psygrid.data.model.hibernate.Entry" not-null="true" name="entry"/>
        <many-to-one column="c_sec_occ_id" cascade="none" class="org.psygrid.data.model.hibernate.SectionOccurrence" not-null="false" name="sectionOccurrence"/>
        <many-to-one column="c_sec_occ_inst_id" cascade="none" class="org.psygrid.data.model.hibernate.SecOccInstance" not-null="false" name="secOccInstance"/>
        <property name="enumStatus" column="c_status"/>
        <property name="annotation" length="4000" column="c_inv_annot" type="text"/>
        <many-to-one column="c_doc_inst_id" cascade="all" class="org.psygrid.data.model.hibernate.DocumentInstance" not-null="false" name="docInstance"/>
        <joined-subclass name="org.psygrid.data.model.hibernate.BasicResponse" table="t_basic_responses">
          <key column="c_id"/>
          <many-to-one unique="true" column="c_value_id" cascade="all" class="org.psygrid.data.model.hibernate.Value" not-null="false" name="theValue"/>
          <list cascade="all" name="oldValues">
            <key not-null="false" column="c_old_br_id"/>
            <list-index column="c_index"/>
            <one-to-many class="org.psygrid.data.model.hibernate.Value"/>
          </list>
        </joined-subclass>
        <joined-subclass name="org.psygrid.data.model.hibernate.CompositeResponse" table="t_comp_responses">
          <key column="c_id"/>
          <list cascade="all" name="compositeRows">
            <key not-null="false" column="c_comp_resp_id"/>
            <list-index column="c_index"/>
            <one-to-many class="org.psygrid.data.model.hibernate.CompositeRow"/>
          </list>
          <list cascade="all" name="deletedRows">
            <key not-null="false" column="c_del_cr_id"/>
            <list-index column="c_del_index"/>
            <one-to-many class="org.psygrid.data.model.hibernate.CompositeRow"/>
          </list>
        </joined-subclass>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.StatusedInstance" table="t_statused_instances">
        <key column="c_id"/>
        <many-to-one column="c_status_id" cascade="none" class="org.psygrid.data.model.hibernate.Status" not-null="false" name="status"/>
        <property name="created" column="c_created"/>
        <property name="createdBy" column="c_created_by"/>
        <property name="edited" column="c_edited"/>
        <property name="editedBy" column="c_edited_by"/>
        <joined-subclass name="org.psygrid.data.model.hibernate.DocumentInstance" table="t_doc_insts">
          <key column="c_id"/>
          <many-to-one column="c_occurrence_id" cascade="none" class="org.psygrid.data.model.hibernate.DocumentOccurrence" not-null="false" name="occurrence"/>
          <set inverse="true" cascade="all" name="responses">
            <key not-null="false" column="c_doc_inst_id"/>
            <one-to-many class="org.psygrid.data.model.hibernate.Response"/>
          </set>
          <list cascade="all" name="secOccInstances">
            <key not-null="false" column="c_doc_inst_id"/>
            <list-index column="c_index"/>
            <one-to-many class="org.psygrid.data.model.hibernate.SecOccInstance"/>
          </list>
        </joined-subclass>
        <joined-subclass name="org.psygrid.data.model.hibernate.Record" table="t_records">
          <key column="c_id"/>
          <property name="scheduleStartDate" column="c_sch_st_date"/>
          <many-to-one column="c_dataset_id" cascade="none" class="org.psygrid.data.model.hibernate.DataSet" not-null="true" name="dataSet"/>
          <set cascade="all" name="consents">
            <key not-null="false" column="c_elem_inst_id"/>
            <one-to-many class="org.psygrid.data.model.hibernate.Consent"/>
          </set>
          <many-to-one unique="true" column="c_identifier_id" cascade="none" class="org.psygrid.data.model.hibernate.Identifier" not-null="true" name="identifier"/>
          <set cascade="all" name="docInstances">
            <key not-null="false" column="c_record_id"/>
            <one-to-many class="org.psygrid.data.model.hibernate.DocumentInstance"/>
          </set>
        </joined-subclass>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Group" table="t_groups">
      <key column="c_id"/>
      <property name="name" column="c_name"/>
      <property name="maxSuffix" column="c_max_suffix"/>
      <many-to-one insert="false" column="c_dataset_id" update="false" class="org.psygrid.data.model.hibernate.DataSet" not-null="true" name="dataSet"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Identifier" table="t_identifiers">
      <key column="c_id"/>
      <property name="identifier" column="c_identifier" unique="true" not-null="true"/>
      <property name="groupPrefix" column="c_group_prefix" not-null="true"/>
      <property name="projectPrefix" column="c_proj_prefix" not-null="true"/>
      <property name="suffix" column="c_suffix" not-null="true"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.OptionDependent" table="t_option_deps">
      <key column="c_id"/>
      <many-to-one unique="false" column="c_entry_id" cascade="none" class="org.psygrid.data.model.hibernate.Entry" not-null="false" name="myDependentEntry"/>
      <many-to-one unique="false" column="c_sec_occ_id" cascade="none" class="org.psygrid.data.model.hibernate.SectionOccurrence" not-null="false" name="myDependentSecOcc"/>
      <property name="enumEntryStatus" column="c_entry_status"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Provenance" table="t_provenance">
      <key column="c_id"/>
      <many-to-one column="c_current_value" cascade="none" class="org.psygrid.data.model.hibernate.Persistent" not-null="false" name="theCurrentValue"/>
      <many-to-one column="c_prev_value" cascade="none" class="org.psygrid.data.model.hibernate.Persistent" not-null="false" name="thePrevValue"/>
      <property name="action" column="c_action"/>
      <property name="timestamp" column="c_timestamp"/>
      <property name="user" column="c_user"/>
      <property name="comment" column="c_comment" type="text"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Reminder" table="t_reminders">
      <key column="c_id"/>
      <property name="time" column="c_time"/>
      <property name="enumUnits" column="c_units"/>
      <property name="enumLevel" column="c_level"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.SecOccInstance" table="t_sec_occ_insts">
      <key column="c_id"/>
      <many-to-one column="c_sec_occ_id" cascade="none" class="org.psygrid.data.model.hibernate.SectionOccurrence" not-null="false" name="sectionOccurrence"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.StandardCode" table="t_std_responses">
      <key column="c_id"/>
      <property name="description" column="c_description" unique="true" not-null="true"/>
      <property name="code" column="c_code" unique="true" not-null="true"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Status" table="t_statuses">
      <key column="c_id"/>
      <property name="code" column="c_code"/>
      <property name="shortName" column="c_short_name" not-null="true"/>
      <property name="longName" column="c_long_name" not-null="true"/>
      <list cascade="none" table="t_status_transitions" name="statusTransitions">
        <key column="c_status_id"/>
        <list-index column="c_index"/>
        <many-to-many class="org.psygrid.data.model.hibernate.Status" column="c_next_status_id"/>
      </list>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Transformer" table="t_transformers">
      <key column="c_id"/>
      <property name="wsNamespace" column="c_namespace"/>
      <property name="wsOperation" column="c_operation"/>
      <property name="wsUrl" column="c_url"/>
      <property name="resultClass" column="c_result_class"/>
      <property name="viewableOutput" column="c_viewable_out"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Unit" table="t_units">
      <key column="c_id"/>
      <property name="abbreviation" column="c_abbrev" not-null="true"/>
      <property name="description" column="c_desc"/>
      <many-to-one unique="false" column="c_base_unit_id" cascade="none" class="org.psygrid.data.model.hibernate.Unit" not-null="false" name="baseUnit"/>
      <property name="factor" column="c_factor"/>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.ValidationRule" table="t_val_rules">
      <key column="c_id"/>
      <property name="description" column="c_description"/>
      <property name="message" column="c_message"/>
      <joined-subclass name="org.psygrid.data.model.hibernate.DateValidationRule" table="t_date_val_rules">
        <key column="c_id"/>
        <property name="absLowerLimit" column="c_abs_lower_limit"/>
        <property name="absUpperLimit" column="c_abs_upper_limit"/>
        <property name="relLowerLimit" column="c_rel_lower_limit"/>
        <property name="relUpperLimit" column="c_rel_upper_limit"/>
        <property name="enumRelLowerUnits" column="c_rel_lower_units"/>
        <property name="enumRelUpperUnits" column="c_rel_upper_units"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.IntegerValidationRule" table="t_int_val_rules">
        <key column="c_id"/>
        <property name="lowerLimit" column="c_lower_limit"/>
        <property name="upperLimit" column="c_upper_limit"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.NumericValidationRule" table="t_num_val_rules">
        <key column="c_id"/>
        <property name="lowerLimit" column="c_lower_limit"/>
        <property name="upperLimit" column="c_upper_limit"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.TextValidationRule" table="t_text_val_rules">
        <key column="c_id"/>
        <property name="lowerLimit" column="c_lower_limit"/>
        <property name="upperLimit" column="c_upper_limit"/>
        <property name="pattern" column="c_pattern"/>
        <property name="patternDetails" column="c_pattern_details"/>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.model.hibernate.Value" table="t_values">
      <key column="c_id"/>
      <property name="deprecated" column="c_deprecated"/>
      <many-to-one column="c_std_code_id" cascade="none" class="org.psygrid.data.model.hibernate.StandardCode" not-null="false" name="standardCode"/>
      <many-to-one column="c_unit_id" cascade="none" class="org.psygrid.data.model.hibernate.Unit" not-null="false" name="unit"/>
      <property name="transformed" column="c_transformed"/>
      <property name="hidden" column="c_hidden"/>
      <joined-subclass name="org.psygrid.data.model.hibernate.BooleanValue" table="t_boolean_values">
        <key column="c_id"/>
        <property name="value" column="c_value"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.DateValue" table="t_date_values">
        <key column="c_id"/>
        <property name="value" column="c_value"/>
        <property name="month" column="c_month"/>
        <property name="year" column="c_year"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.IntegerValue" table="t_integer_values">
        <key column="c_id"/>
        <property name="value" column="c_value"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.LongTextValue" table="t_long_text_values">
        <key column="c_id"/>
        <property name="value" column="c_value" type="text"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.NumericValue" table="t_numeric_values">
        <key column="c_id"/>
        <property name="value" column="c_value"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.OptionValue" table="t_option_values">
        <key column="c_id"/>
        <many-to-one column="c_option_id" cascade="none" class="org.psygrid.data.model.hibernate.Option" not-null="false" name="value"/>
        <property name="textValue" column="c_text_value"/>
      </joined-subclass>
      <joined-subclass name="org.psygrid.data.model.hibernate.TextValue" table="t_text_values">
        <key column="c_id"/>
        <property name="value" length="256" column="c_value"/>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.reporting.definition.hibernate.Chart" table="t_charts">
      <key column="c_id"/>
      <property name="type" column="c_type"/>
      <property name="title" column="c_title"/>
      <property name="showLabels" column="c_show_labels"/>
      <joined-subclass name="org.psygrid.data.reporting.definition.hibernate.SimpleChart" table="t_simple_charts">
        <key column="c_id"/>
        <list cascade="all" name="items">
          <key not-null="true" column="c_sim_chart_id"/>
          <list-index column="c_index"/>
          <one-to-many class="org.psygrid.data.reporting.definition.hibernate.SimpleChartItem"/>
        </list>
      </joined-subclass>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.reporting.definition.hibernate.Report" table="t_reports">
      <key column="c_id"/>
      <many-to-one unique="false" column="c_dataset_id" cascade="none" class="org.psygrid.data.model.hibernate.DataSet" not-null="true" name="dataSet"/>
      <property name="title" column="c_title"/>
      <list cascade="all" name="charts">
        <key not-null="true" column="c_report_id"/>
        <list-index column="c_index"/>
        <one-to-many class="org.psygrid.data.reporting.definition.hibernate.Chart"/>
      </list>
    </joined-subclass>
    <joined-subclass name="org.psygrid.data.reporting.definition.hibernate.SimpleChartItem" table="t_simple_chart_items">
      <key column="c_id"/>
      <many-to-one unique="false" column="c_doc_occ_id" cascade="none" class="org.psygrid.data.model.hibernate.DocumentOccurrence" not-null="true" name="docOccurrence"/>
      <many-to-one unique="false" column="c_entry_id" cascade="none" class="org.psygrid.data.model.hibernate.Entry" not-null="true" name="entry"/>
      <many-to-one unique="false" column="c_sec_occ_id" cascade="none" class="org.psygrid.data.model.hibernate.SectionOccurrence" not-null="true" name="secOccurrence"/>
      <property name="options" column="c_options"/>
    </joined-subclass>
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

[code]
2006-05-17 16:51:22,973 [http-8080-Processor23] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1116, SQLState: HY000
2006-05-17 16:51:22,973 [http-8080-Processor23] ERROR org.hibernate.util.JDBCExceptionReporter - Too many tables; MySQL can only use 61 tables in a join
2006-05-17 16:51:22,973 [http-8080-Processor23] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
org.hibernate.exception.GenericJDBCException: could not load an entity: [org.psygrid.data.model.hibernate.Persistent#591]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:82)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:849)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:62)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at org.psygrid.data.model.hibernate.Persistent$$EnhancerByCGLIB$$c681b758.toDTO(<generated>)
at org.psygrid.data.model.hibernate.Provenance.toDTO(Provenance.java:225)
at org.psygrid.data.model.hibernate.Provenance.toDTO(Provenance.java:217)
at org.psygrid.data.model.hibernate.ElementInstance.toDTO(ElementInstance.java:165)
at org.psygrid.data.model.hibernate.StatusedInstance.toDTO(StatusedInstance.java:238)
at org.psygrid.data.model.hibernate.DocumentInstance.toDTO(DocumentInstance.java:310)
at org.psygrid.data.model.hibernate.DocumentInstance.toDTO(DocumentInstance.java:304)
at org.psygrid.data.model.hibernate.Record.toDTO(Record.java:335)
at org.psygrid.data.model.hibernate.Record.toDTO(Record.java:290)
at org.psygrid.data.model.hibernate.Record.toDTO(Record.java:268)
at org.psygrid.data.dao.hibernate.RecordDAOHibernate$2.doInHibernate(RecordDAOHibernate.java:218)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:331)
at org.psygrid.data.dao.hibernate.RecordDAOHibernate.getRecordsDocumentsByStatus(RecordDAOHibernate.java:230)
at org.psygrid.data.dao.hibernate.RepositoryDAOHibernate.getRecordsDocumentsByStatus(RepositoryDAOHibernate.java:215)
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:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.psygrid.data.dao.hibernate.DAOInterceptor.invoke(DAOInterceptor.java:41)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy3.getRecordsDocumentsByStatus(Unknown Source)
at org.psygrid.data.RepositorySoapBindingImpl.getRecordsDocumentsByStatus(RepositorySoapBindingImpl.java:836)
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:585)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: Too many tables; MySQL can only use 61 tables in a join
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2921)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:930)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1024)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 71 more
2006-05-17 16:51:22,982 [http-8080-Processor23] ERROR org.psygrid.data.RepositorySoapBindingImpl - getRecordsDocumentsByStatus: DAOException
org.psygrid.data.dao.DAOException: Data Access Exception: Hibernate operation: could not load an entity: [org.psygrid.data.model.hibernate.Persistent#591]; uncategorized SQLException for SQL [select persistent0_.c_id as c1_10_0_, persistent0_.c_version as c2_10_0_, persistent0_1_.c_data as c2_11_0_, persistent0_2_.c_data_id as c2_12_0_, persistent0_2_.c_description as c3_12_0_, persistent0_2_.c_file_name as c4_12_0_, persistent0_2_.c_mime_type as c5_12_0_, persistent0_3_.c_name as c2_13_0_, persistent0_3_.c_description as c3_13_0_, persistent0_3_.c_display_text as c4_13_0_, persistent0_4_.c_label as c2_14_0_, persistent0_5_.c_label as c2_15_0_, persistent0_5_.c_doc_id as c3_15_0_, persistent0_5_.c_doc_grp_id as c4_15_0_, persistent0_5_.c_time as c5_15_0_, persistent0_5_.c_units as c6_15_0_, persistent0_6_.c_dataset_id as c2_16_0_, persistent0_7_.c_label as c2_17_0_, persistent0_7_.c_section_id as c3_17_0_, persistent0_7_.c_entry_status as c4_17_0_, persistent0_10_.c_format as c2_23_0_, persistent0_11_.c_formula as c2_24_0_, persistent0_11_.c_agg_opertr as c3_24_0_, persistent0_11_.c_composite_id as c4_24_0_, persistent0_12_.c_default as c2_26_0_, persistent0_14_.c_default as c2_28_0_, persistent0_15_.c_default_id as c2_29_0_, persistent0_15_.c_disp_codes as c3_29_0_, persistent0_16_.c_text_size as c2_30_0_, persistent0_18_.c_style as c2_33_0_, persistent0_20_.c_version as c2_35_0_, persistent0_20_.c_published as c3_35_0_, persistent0_20_.c_e_doc as c4_35_0_, persistent0_20_.c_date_modified as c5_35_0_, persistent0_20_.c_suffix_size as c6_35_0_, persistent0_20_.c_project_code as c7_35_0_, persistent0_20_.c_sch_st_qu as c8_35_0_, persistent0_22_.c_code as c2_38_0_, persistent0_22_.c_text_allowed as c3_38_0_, persistent0_22_.c_entry_id as c4_38_0_, persistent0_24_.c_label as c2_40_0_, persistent0_24_.c_section_id as c3_40_0_, persistent0_24_.c_entry_status as c4_40_0_, persistent0_24_.c_multiple_allowed as c5_40_0_, persistent0_25_.c_e_doc as c2_41_0_, persistent0_25_.c_consent_given as c3_41_0_, persistent0_25_.c_location as c4_41_0_, persistent0_25_.c_cons_form_id as c5_41_0_, persistent0_26_.c_e_doc as c2_42_0_, persistent0_26_.c_question as c3_42_0_, persistent0_26_.c_ref_no as c4_42_0_, persistent0_27_.c_cf_id as c2_43_0_, persistent0_28_.c_group_id as c2_44_0_, persistent0_29_.c_description as c2_45_0_, persistent0_29_.c_dataset_id as c3_45_0_, persistent0_30_.c_record_id as c2_46_0_, persistent0_31_.c_comp_resp_id as c2_47_0_, persistent0_32_.c_entry_id as c2_48_0_, persistent0_32_.c_sec_occ_id as c3_48_0_, persistent0_32_.c_sec_occ_inst_id as c4_48_0_, persistent0_32_.c_status as c5_48_0_, persistent0_32_.c_inv_annot as c6_48_0_, persistent0_32_.c_doc_inst_id as c7_48_0_, persistent0_33_.c_value_id as c2_49_0_, persistent0_35_.c_status_id as c2_51_0_, persistent0_35_.c_created as c3_51_0_, persistent0_35_.c_created_by as c4_51_0_, persistent0_35_.c_edited as c5_51_0_, persistent0_35_.c_edited_by as c6_51_0_, persistent0_36_.c_occurrence_id as c2_52_0_, persistent0_37_.c_sch_st_date as c2_53_0_, persistent0_37_.c_dataset_id as c3_53_0_, persistent0_37_.c_identifier_id as c4_53_0_, persistent0_38_.c_name as c2_54_0_, persistent0_38_.c_max_suffix as c3_54_0_, persistent0_38_.c_dataset_id as c4_54_0_, persistent0_39_.c_identifier as c2_55_0_, persistent0_39_.c_group_prefix as c3_55_0_, persistent0_39_.c_proj_prefix as c4_55_0_, persistent0_39_.c_suffix as c5_55_0_, persistent0_40_.c_entry_id as c2_56_0_, persistent0_40_.c_sec_occ_id as c3_56_0_, persistent0_40_.c_entry_status as c4_56_0_, persistent0_41_.c_current_value as c2_57_0_, persistent0_41_.c_prev_value as c3_57_0_, persistent0_41_.c_action as c4_57_0_, persistent0_41_.c_timestamp as c5_57_0_, persistent0_41_.c_user as c6_57_0_, persistent0_41_.c_comment as c7_57_0_, persistent0_42_.c_time as c2_58_0_, persistent0_42_.c_units as c3_58_0_, persistent0_42_.c_level as c4_58_0_, persistent0_43_.c_sec_occ_id as c2_59_0_, persistent0_44_.c_description as c2_60_0_, persistent0_44_.c_code as c3_60_0_, persistent0_45_.c_code as c2_61_0_, persistent0_45_.c_short_name as c3_61_0_, persistent0_45_.c_long_name as c4_61_0_, persistent0_46_.c_namespace as c2_63_0_, persistent0_46_.c_operation as c3_63_0_, persistent0_46_.c_url as c4_63_0_, persistent0_46_.c_result_class as c5_63_0_, persistent0_46_.c_viewable_out as c6_63_0_, persistent0_47_.c_abbrev as c2_64_0_, persistent0_47_.c_desc as c3_64_0_, persistent0_47_.c_base_unit_id as c4_64_0_, persistent0_47_.c_factor as c5_64_0_, persistent0_48_.c_description as c2_65_0_, persistent0_48_.c_message as c3_65_0_, persistent0_49_.c_abs_lower_limit as c2_66_0_, persistent0_49_.c_abs_upper_limit as c3_66_0_, persistent0_49_.c_rel_lower_limit as c4_66_0_, persistent0_49_.c_rel_upper_limit as c5_66_0_, persistent0_49_.c_rel_lower_units as c6_66_0_, persistent0_49_.c_rel_upper_units as c7_66_0_, persistent0_50_.c_lower_limit as c2_67_0_, persistent0_50_.c_upper_limit as c3_67_0_, persistent0_51_.c_lower_limit as c2_68_0_, persistent0_51_.c_upper_limit as c3_68_0_, persistent0_52_.c_lower_limit as c2_69_0_, persistent0_52_.c_upper_limit as c3_69_0_, persistent0_52_.c_pattern as c4_69_0_, persistent0_52_.c_pattern_details as c5_69_0_, persistent0_53_.c_deprecated as c2_70_0_, persistent0_53_.c_std_code_id as c3_70_0_, persistent0_53_.c_unit_id as c4_70_0_, persistent0_53_.c_transformed as c5_70_0_, persistent0_53_.c_hidden as c6_70_0_, persistent0_54_.c_value as c2_71_0_, persistent0_55_.c_value as c2_72_0_, persistent0_55_.c_month as c3_72_0_, persistent0_55_.c_year as c4_72_0_, persistent0_56_.c_value as c2_73_0_, persistent0_57_.c_value as c2_74_0_, persistent0_58_.c_value as c2_75_0_, persistent0_59_.c_option_id as c2_76_0_, persistent0_59_.c_text_value as c3_76_0_, persistent0_60_.c_value as c2_77_0_, persistent0_61_.c_type as c2_78_0_, persistent0_61_.c_title as c3_78_0_, persistent0_61_.c_show_labels as c4_78_0_, persistent0_63_.c_dataset_id as c2_80_0_, persistent0_63_.c_title as c3_80_0_, persistent0_64_.c_doc_occ_id as c2_81_0_, persistent0_64_.c_entry_id as c3_81_0_, persistent0_64_.c_sec_occ_id as c4_81_0_, persistent0_64_.c_options as c5_81_0_, case when persistent0_9_.c_id is not null then 9 when persistent0_10_.c_id is not null then 10 when persistent0_11_.c_id is not null then 11 when persistent0_12_.c_id is not null then 12 when persistent0_13_.c_id is not null then 13 when persistent0_14_.c_id is not null then 14 when persistent0_15_.c_id is not null then 15 when persistent0_16_.c_id is not null then 16 when persistent0_8_.c_id is not null then 8 when persistent0_17_.c_id is not null then 17 when persistent0_18_.c_id is not null then 18 when persistent0_20_.c_id is not null then 20 when persistent0_21_.c_id is not null then 21 when persistent0_7_.c_id is not null then 7 when persistent0_19_.c_id is not null then 19 when persistent0_4_.c_id is not null then 4 when persistent0_5_.c_id is not null then 5 when persistent0_6_.c_id is not null then 6 when persistent0_22_.c_id is not null then 22 when persistent0_23_.c_id is not null then 23 when persistent0_24_.c_id is not null then 24 when persistent0_27_.c_id is not null then 27 when persistent0_28_.c_id is not null then 28 when persistent0_33_.c_id is not null then 33 when persistent0_34_.c_id is not null then 34 when persistent0_36_.c_id is not null then 36 when persistent0_37_.c_id is not null then 37 when persistent0_31_.c_id is not null then 31 when persistent0_32_.c_id is not null then 32 when persistent0_35_.c_id is not null then 35 when persistent0_49_.c_id is not null then 49 when persistent0_50_.c_id is not null then 50 when persistent0_51_.c_id is not null then 51 when persistent0_52_.c_id is not null then 52 when persistent0_54_.c_id is not null then 54 when persistent0_55_.c_id is not null then 55 when persistent0_56_.c_id is not null then 56 when persistent0_57_.c_id is not null then 57 when persistent0_58_.c_id is not null then 58 when persistent0_59_.c_id is not null then 59 when persistent0_60_.c_id is not null then 60 when persistent0_62_.c_id is not null then 62 when persistent0_1_.c_id is not null then 1 when persistent0_2_.c_id is not null then 2 when persistent0_3_.c_id is not null then 3 when persistent0_25_.c_id is not null then 25 when persistent0_26_.c_id is not null then 26 when persistent0_29_.c_id is not null then 29 when persistent0_30_.c_id is not null then 30 when persistent0_38_.c_id is not null then 38 when persistent0_39_.c_id is not null then 39 when persistent0_40_.c_id is not null then 40 when persistent0_41_.c_id is not null then 41 when persistent0_42_.c_id is not null then 42 when persistent0_43_.c_id is not null then 43 when persistent0_44_.c_id is not null then 44 when persistent0_45_.c_id is not null then 45 when persistent0_46_.c_id is not null then 46 when persistent0_47_.c_id is not null then 47 when persistent0_48_.c_id is not null then 48 when persistent0_53_.c_id is not null then 53 when persistent0_61_.c_id is not null then 61 when persistent0_63_.c_id is not null then 63 when persistent0_64_.c_id is not null then 64 when persistent0_.c_id is not null then 0 end as clazz_0_ from t_persistents persistent0_ left outer join t_binary_data persistent0_1_ on persistent0_.c_id=persistent0_1_.c_id left outer join t_binary_objects persistent0_2_ on persistent0_.c_id=persistent0_2_.c_id left outer join t_components persistent0_3_ on persistent0_.c_id=persistent0_3_.c_id left outer join t_doc_group


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 12:41 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Hibernate is joining all of the tables for that class together in an outer join so that it can provide implicit polymorphism. Do you need this? If not, switching to explicit polymorphism should do the trick.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 2:05 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
information from reference docs related
http://www.hibernate.org/117.html#A28


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 5:59 am 
Newbie

Joined: Fri Sep 16, 2005 8:05 am
Posts: 7
Hi,

Thanks for your replies. I have tried setting polymorphism="explicit" on the base class but that didn't seem to have any effect - I still get the "too many tables" exception.

Having read the section of the Hibernate docs regarding implicit and explicit polymorphism too be honest I'm still not 100% sure that I understand what all this is about! What I do find interesting thought is that I am getting this problem during lazy-loading, not when I am executing a query.

Any more advice greatfully received!

Rob


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 6:26 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Ok, here's what I think is happening... You've got a large amount of classes in a table per concrete class hierarchy. You've got some kind of association to an instance of this class an Hibernate is trying to lazily load it. All it has to do this is the id. It doesn't know which subclass the object that it is trying to load will be, so it left outer joins all of the tables in the class hierarchy together on the id and then looks for the first subclass table that returns a row to determine the type. This means that you get a join per class table in this type of mapping. The only solutions that I can see are to either:

1) Change to a 'Table per class hierarchy' model for this class. This would mean that you'd have all of your columns in one table and therefore no joins at all in this case. It would be a very wide table though - I don't know what the limit is in MySQL

2) Change to use an 'Any' association for the actual data - this would allow you to have a discriminator which Hibernate could use to work out what table it needs.

Hope that helps,
Cheers,
Rich.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 7:57 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
This is partly a sign that your db structure and mapping style is bad.

You can move the id and version to each subclass-table so you have a table per concrete class (or at least every object will not have its key in one giant table).

This way your joins will be from a particular table to a particular table, colving the 61 joins issue.

Also, your database structure will be more natural: E.g. if Class A has a many-many relation to class B you will have a join table joining tableA to tableB, rather than an uninformative join table from Persistent to Persistent.

The *mapping* for id and version *may* be able to stay at the superclass level if the field name in each table is the same, particularly using annotations or xdoclet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 10:20 am 
Newbie

Joined: Fri Sep 16, 2005 8:05 am
Posts: 7
You are right, it was poor design that was causing my problem; I had a many-to-one relationship to the base class Persistent, which was the cause of the joins across all tables in the database. I have now changed my design slightly so that I no longer need the many-to-one to Persistent, and all is now working fine.

Thanks a lot for all of the help.

cheers, Rob


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