-->
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.  [ 4 posts ] 
Author Message
 Post subject: Found shared references to a collection
PostPosted: Wed Jan 26, 2005 7:44 am 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi all,

I must insert the objects Company, MonthlyFee and Transaction Tax.
I´m trying to insert objects into database, but occurs
the problem specified bellow when, in the java
code, I try to execute dataSource.insert(monthlyFee, session);

Hibernate version: 2.0.2

Mapping documents:

Code:

<!-- Commpany -->
<hibernate-mapping>
    <class name="manager.Company" table="empresa">
      <id name="cnpj" column="cnpj">
         <generator class="assigned"/>
      </id>
      <property name="name" column="nome"/>
      <property name="corporateName" column="razao_social"/>
      <property name="address" column="logradouro"/>
      <property name="number" column="numero"/>
      <property name="complement" column="complemento"/>
      <property name="burgh" column="bairro"/>
        <many-to-one name="city" column="id_cidade"
         class="manager.City"/>
         <one-to-one name="transactionTax" class="transaction.TransactionTax"
            constrained="false" outer-join="true"/>
        <bag name="monthlyFees" inverse="true" lazy="false">
         <key column="cnpj"/>
         <one-to-many class="access.MonthlyFee"/>
        </bag>
    </class>
</hibernate-mapping>


<!-- transactionTax -->

<hibernate-mapping>
    <class name="transaction.TransactionTax" table="transacao_taxa">
        <id name="cnpj" column="cnpj">
           <generator class="foreign">
              <param name="property">company</param>
           </generator>
         </id>
         <one-to-one constrained="true" outer-join="false" name="company"
            class="manager.Company"/>
        <property name="fgTransactionTax" column="fg_transacao_taxa"/>
        <property name="value" column="valor"/>
        <property name="percentage" column="porcentagem"/>
        <property name="limit" column="limite"/>
    </class>
</hibernate-mapping>


<!-- monthlyFees -->

<hibernate-mapping>
    <class name="access.MonthlyFee" table="mensalidade">
      <id name="idMonthlyFee" column="id_mensalidade">
         <generator class="assigned"/>
      </id>
        <many-to-one name="company" column="cnpj"
           class="manager.Company"/>
      <many-to-one name="expirationDay" column="id_dia_vencimento"
         class="access.ExpirationDay"/>
        <property name="value" column="valor"/>
      <many-to-one name="monthlyFeeStatus" column="id_mensalidade_status"
         class="access.MonthlyFeeStatus"/>
      <many-to-one name="companyStatus" column="id_empresa_status"
         class="manager.CompanyStatus"/>     
        <property name="dtPayment" column="dt_pagamento"/>
        <property name="dtExpiration" column="dt_vencimento"/>
      <property name="tpCharge" column="tp_cobranca"/>
      <property name="agency" column="agencia"/>
      <property name="cdCustomer" column="cd_cliente"/>
      <property name="dtGeneration" column="dt_geracao"/>      
      <bag name="parcels" inverse="true" lazy="false">
         <key column="id_mensalidade"/>
         <one-to-many class="trip.Parcel"/>
        </bag>       
      <bag name="tolls" inverse="true" lazy="false">
         <key column="id_mensalidade"/>
         <one-to-many class="trip.Toll"/>
        </bag>       
    </class>
</hibernate-mapping>





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

Code:

            session = dataSource.openSession();
            tx = session.beginTransaction();

         // --- inserts the company ---
         dataSource.insert(company, session);
         
         // --- inserts the unique Monthlyfee from the list ---
         MonthlyFee monthlyFee = (MonthlyFee) company.getMonthlyFees().get(0);
         
         dataSource.insert(monthlyFee, session);

         // --- inserts the transaction tax ---
         TransactionTax transactionTax = company.getTransactionTax();
         
         dataSource.insert(transactionTax, session);



Full stack trace of any exception that occurs:

Code:

net.sf.hibernate.HibernateException: Found shared references to a collection



Name and version of the database you are using: Oracle 8i

The generated SQL (show_sql=true):

Code:
2005-01-26 09:18:46,031 - INFO STDOUT - Hibernate: insert into empresa (nome, razao_social, logradouro, numero, complemento, bairro, id_cidade, cnpj) values (?, ?, ?, ?, ?, ?, ?, ?)



Please, somebody can help me???

thanks!
[/code]

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 2:02 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
I again,

I saw that the error occurs when the session.flush() is executed.
What can be?

_________________
Tads


Top
 Profile  
 
 Post subject: same problem
PostPosted: Thu Jun 02, 2005 10:26 am 
Newbie

Joined: Mon Apr 19, 2004 5:56 am
Posts: 9
Hi,
i got the same problem about found shared references...
Have you solve it ?

Best regards.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 8:26 pm 
Newbie

Joined: Mon Aug 29, 2005 7:21 pm
Posts: 1
Hi.
I got the same error.
I find answer for 2 days :)
In my case this was error in clone() method.
class.coll = coll.addAll(coll);
So here occured shared references.

Check in your code for shared references in collections, etc.
ICQ 164327187


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