hibernate + java.lang.StackOverflowError

时间:2012-03-05 12:45:15

标签: hibernate stack-overflow

我收到的错误是:

java.lang.StackOverflowError 
        java.nio.Buffer.<init>(Buffer.java:176) 
        java.nio.ByteBuffer.<init>(ByteBuffer.java:259) 
        java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:52) 
        java.nio.ByteBuffer.wrap(ByteBuffer.java:350) 
        java.nio.ByteBuffer.wrap(ByteBuffer.java:373) 
        java.lang.StringCoding$StringEncoder.encode(StringCoding.java:237) 
        java.lang.StringCoding.encode(StringCoding.java:272) 
        java.lang.String.getBytes(String.java:946) 

只有在我在product hbm文件中添加了与productCategories的关系后才会添加此错误。 请建议

productCategory和product hbm文件是:

<?xml version="1
<hibernate-mapping package="com.quinstreet.persistence.productCatalogue"
default-cascade="save-update">
<class
    name="com.quinstreet.persistence.productCatalogue.ProductCategoryDBVO"
    table="PRD_PRODUCT_CATEGORY" lazy="false">
            <cache usage="nonstrict-read-write" />
    <composite-id>
        <key-many-to-one name="product"
            class="com.quinstreet.persistence.product.ProductDBVO" column="PRODUCT_GUID" lazy="false"
            foreign-key="FK_PRD_PRODUCT_FK1" />
        <key-many-to-one name="category"
class="com.quinstreet.persistence.productCatalogue.CategoryMasterDBVO"
            column="CATEGORY_GUID" foreign-key="FK_PRD_CATEGORY_MASTER_FK1" />
    </composite-id>
    <property name="displaySequence" column="DISPLAY_SEQUENCE"
        type="java.lang.Integer" />
</class>
</hibernate-mapping>

以下是产品hbm文件:

 <hibernate-mapping package="com.quinstreet.persistence.product" default-cascade="save-update">

 <!-- Abstract product definition -->
 <class name="com.quinstreet.persistence.product.ProductDBVO" table="PRD_PRODUCT"  lazy="false">

  <cache usage="nonstrict-read-write"/>

<!-- Unique identifier for the product -->
<id name="guid" type="java.lang.Long">
   <meta attribute="scope-set">protected</meta>
   <column name="guid"/>
   <generator class="com.quinstreet.persistence.GuidGenerator"/>
</id>

<!-- Version field -->
<!--<version name="version"/>-->

<!-- Discontinued flag -->
<property name="discontinued" type="boolean" not-null="true"/>

<!-- New product flag -->
<property name="newImport" type="boolean" not-null="true"/>

<!-- EIS identifier -->
<property name="eisIdentifier" type="string" unique="true" not-null="true" index="IDX_PRD_PRODUCT_EIS">
     <meta attribute="use-in-equals">true</meta>
</property>

  <!-- Update stock-count on allocation? -->
  <property name="stocked" type="boolean" not-null="true"/>

  <!-- Is this a prototype value? -->
  <property name="prototype" type="boolean" not-null="true"/>

  <property name="plcCode" type="string" not-null="false" column="plc_code"/>

<!-- References to legacy tables -->
<many-to-one name="availability" column="availabilityGuid" class="com.quinstreet.persistence.product.AvailabilityDBVO" foreign-key="FK_PRD_PRODUCT_AVAILABILITY" cascade="none"> 
    <meta attribute="property-type">com.quinstreet.domain.product.Availability</meta>
</many-to-one>
<many-to-one name="taxBand" column="taxBandGuid" class="com.quinstreet.persistence.tax.BandDBVO" foreign-key="FK_PRD_PRODUCT_TAX_BAND" cascade="none"> 
    <meta attribute="property-type">com.quinstreet.domain.tax.Band</meta>
</many-to-one>

<!-- Normalised Legacy Product Class -->
<many-to-one name="productClass" column="productClassGuid" class="com.quinstreet.persistence.product.ProductClassDBVO" foreign-key="FK_PRD_PRODUCT_CLASS" cascade="none">
    <meta attribute="property-type">com.quinstreet.domain.product.ProductClass</meta>
</many-to-one>

<!-- Normalised Legacy Product Type -->
<many-to-one name="productType" column="productTypeGuid" class="com.quinstreet.persistence.product.ProductTypeDBVO" foreign-key="FK_PRD_PRODUCT_TYPE" cascade="none">
    <meta attribute="property-type">com.quinstreet.domain.product.ProductType</meta>
</many-to-one>

<!-- Product-family this product belongs to -->
<many-to-one name="group" column="groupGuid" class="com.quinstreet.persistence.product.ProductGroupDBVO" foreign-key="FK_PRD_PRODUCT_GROUP" cascade="none" fetch="join">
    <meta attribute="property-type">com.quinstreet.domain.product.MasterProduct</meta>
</many-to-one>

  <many-to-one name="salesCategory1" column="sales_category_guid_1" class="com.quinstreet.persistence.product.SalesCategoryDBVO" foreign-key="fk_product_sc1" cascade="none"/>
  <many-to-one name="salesCategory2" column="sales_category_guid_2" class="com.quinstreet.persistence.product.SalesCategoryDBVO" foreign-key="fk_product_sc2" cascade="none"/>
  <many-to-one name="salesCategory3" column="sales_category_guid_3" class="com.quinstreet.persistence.product.SalesCategoryDBVO" foreign-key="fk_product_sc3" cascade="none"/>
  <many-to-one name="salesCategory4" column="sales_category_guid_4" class="com.quinstreet.persistence.product.SalesCategoryDBVO" foreign-key="fk_product_sc4" cascade="none"/>
  <many-to-one name="salesCategory5" column="sales_category_guid_5" class="com.quinstreet.persistence.product.SalesCategoryDBVO" foreign-key="fk_product_sc5" cascade="none"/>

<!-- Product pricing -->
<set name="prices" inverse="true" table="PRD_PRICE" lazy="true">
   <cache usage="nonstrict-read-write"/>

   <key column="productGuid" foreign-key="FK_PRD_PRICE_PRODUCT"/>

   <one-to-many class="com.quinstreet.persistence.product.PriceParametersDBVO"/>
</set>

<!-- Dimension-Values associated with this product -->
<set name="dimensionValues" table="PRD_PRODUCT_DIMENSION_VALUE" lazy="true" batch-size="25" cascade="none">
   <cache usage="nonstrict-read-write"/>

   <key column="productGuid" foreign-key="FK_PRD_PRODDIMVAL_PRODUCT"/>

    <many-to-many class="com.quinstreet.persistence.product.dimension.DimensionValueDBVO" column="dimensionValueGuid" foreign-key="FK_PRD_PRODDIMVAL_DIMVAL"/>
</set>

  <!-- Reference to default Sku's -->
  <set name="defaultSkus" table="PRD_SKU" inverse="true" lazy="true" where="defaultSku=1">
   <cache usage="nonstrict-read-write"/>

     <key column="productGuid" foreign-key="FK_PRD_SKU_PRODUCT"/>

     <one-to-many class="com.quinstreet.persistence.product.SkuDBVO"/>
  </set>

  <!-- Reference to all non-default Sku's -->
  <set name="nonDefaultSkus" table="PRD_SKU" inverse="true" lazy="true" where="defaultSku!=1">
   <cache usage="nonstrict-read-write"/>

     <key column="productGuid" foreign-key="FK_PRD_SKU_PRODUCT"/>

     <one-to-many class="com.quinstreet.persistence.product.SkuDBVO"/>
  </set>

  <!-- Reference to inventory entries -->
  <set name="inventories" table="PRD_INVENTORY" inverse="true" lazy="true">
     <cache usage="nonstrict-read-write"/>

     <key column="productGuid" foreign-key="FK_PRD_INVENTORY_PRODUCT"/>

     <one-to-many class="com.quinstreet.persistence.product.InventoryDBVO"/>
  </set>

  <!-- References to containing PackComponents -->
  <set name="containingPackComponents" table="PRD_PACK_COMPONENT" inverse="true" lazy="true" cascade="none">
     <cache usage="nonstrict-read-write"/>

     <key column="productGuid" foreign-key="FK_PRD_PACKCOMP_PRODUCT2"/>

     <one-to-many class="com.quinstreet.persistence.product.PackComponentDBVO"/>
  </set>


<set name="productCategories" table="PRD_PRODUCT_CATEGORY" lazy="true" batch-size="25" inverse="true"
    fetch="join">
    <cache usage="nonstrict-read-write"/>
    <key>
        <column name="PRODUCT_GUID" not-null="true" />
    </key>
    <one-to-many class="com.quinstreet.persistence.productCatalogue.ProductCategoryDBVO" />
</set>

<set name="recommendations" table="PRD_PRODUCT_RECOMMENDATION" inverse="true" lazy="true" batch-size="25" fetch="select">
 <cache usage="nonstrict-read-write"/>   
  <key column="productguid" not-null="true"/>
  <one-to-many class="com.quinstreet.persistence.productCatalogue.ProductRecommendationDBVO" />
</set>

<!-- L10n details -->
<idbag name="details" table="PRD_PRODUCT_L10N" lazy="true" batch-size="25">
   <cache usage="nonstrict-read-write"/>

   <collection-id type="long" column="guid">
        <meta attribute="scope-set">protected</meta>
        <!--<column name="guid"/>-->
        <generator class="com.quinstreet.persistence.GuidGenerator"/>
   </collection-id>

   <key column="productGuid" foreign-key="FK_PRD_PRODUCTL10N_PRODUCT"/>

   <composite-element class="com.quinstreet.persistence.product.ProductL10nDetailsDBVO">
        <meta attribute="implements">com.quinstreet.domain.product.ProductL10nDetails</meta>
        <meta attribute="extends">com.quinstreet.domain.l10n.AbstractL10nDetails</meta>
        <meta attribute="implement-equals" inherit="false">true</meta>

    <many-to-one name="localeDbvo" class="com.quinstreet.persistence.l10n.LocaleDBVO" column="localeGuid" not-null="true" foreign-key="FK_PRD_PRODUCTL10N_LOCALE" cascade="none">
           <meta attribute="property-type">com.quinstreet.persistence.l10n.LocaleDBVO</meta>
           <meta attribute="use-in-equals">true</meta>
    </many-to-one>
    <many-to-one name="realmDbvo" class="com.quinstreet.persistence.context.RealmDBVO" column="realmGuid" not-null="true" foreign-key="FK_PRD_PRODUCTL10N_REALM" cascade="none">
           <meta attribute="property-type">com.quinstreet.persistence.context.RealmDBVO</meta>
           <meta attribute="use-in-equals">true</meta>
    </many-to-one>

    <property name="description" type="string"/>
    <property name="longDescription" type="string"/>
    <property name="eisDescription" type="string"/>

    <property name="noStockMessage" type="string"/>

        <!-- Generic product attribute holders -->
        <property name="genericAttribute1" type="string"/>
        <property name="genericAttribute2" type="string"/>
        <property name="genericAttribute3" type="string"/>
        <property name="genericAttribute4" type="string"/>
        <property name="genericAttribute5" type="string"/>
        <property name="genericAttribute6" type="string"/>

        <property name="genericName" type="string" column="GENERIC_NAME"/>
        <property name="ingredients" type="string"/>
        <property name="quantity" type="string"/>
        <property name="nutritionFacts" type="string" column="NUTRITION_FACTS"/>
        <property name="dose" type="string"/>
        <property name="catchingPhrase" type="string" column="CATCHING_PHRASE"/>
        <!-- property name="recommendedFor" type="string" column="RECOMMENDED_FOR"/-->
        <property name="promotionMsg" type="string" column="PROMOTION_MESSAGE"/>
        <property name="message" type="string"/>
        <property name="productDescription" type="string" column="PRODUCT_DESCRIPTION"/>
        <property name="notViewable" type="yes_no"  column="SUPPRESS_WEB_VIEWABLE"/>
        <!-- property name="displaySequence" type="integer" column="DISPLAY_SEQUENCE"/-->

   </composite-element>
</idbag>


  <!-- Pack definition -->
  <joined-subclass name="com.quinstreet.persistence.product.PackDBVO" table="PRD_PACK" lazy="false">
     <key column="productGuid" foreign-key="FK_PRD_PACK_PRODUCT"/>

     <!-- Should lines be displayed? -->
     <property name="itemsVisible" type="boolean" not-null="true"/>

     <!-- Pack type -->
     <many-to-one name="packType" class="com.quinstreet.persistence.product.PackTypeDBVO" column="packTypeGuid" not-null="true"  foreign-key="FK_PRD_PACK_PACKTYPE" cascade="none">
        <meta attribute="property-type">com.quinstreet.domain.product.PackType</meta>
     </many-to-one>

     <!-- Status flags -->
     <property name="componentsValid" type="boolean" not-null="true"/>
     <property name="pricesValid" type="boolean" not-null="true"/>

     <!-- Pack components -->
     <set name="packComponents" table="PRD_PACK_COMPONENT" lazy="true" inverse="true">
       <cache usage="nonstrict-read-write"/>

        <key column="packProductGuid" foreign-key="FK_PRD_PACKCOMPONENT_PACK"/>

        <one-to-many class="com.quinstreet.persistence.product.PackComponentDBVO"/>
     </set>

  </joined-subclass>

   

在产品hbm中评论后,它的效果很好                                                                                                                    

   <set name="recommendations" table="PRD_PRODUCT_RECOMMENDATION" inverse="true" lazy="true" batch-size="25" fetch="select"> 
 <cache usage="nonstrict-read-write"/>   
  <key column="productguid" not-null="true"/> 
  <one-to-many class="com.quinstreet.persistence.productCatalogue.ProductRecommendationDBVO" /> 
</set> 

1 个答案:

答案 0 :(得分:0)

确保在某些类中覆盖它而不是调用超级版本时不会调用相同的方法:

public void setWhatever(Whatever whatever) {
   super.setWhatever(whatever);
   this.whateverSet = true;
}

public void setWhatever(Whatever whatever) {
   setWhatever(whatever);
   this.whateverSet = true;
}