-->
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.  [ 3 posts ] 
Author Message
 Post subject: Delete object; Flush session; Session.find gets object
PostPosted: Tue Apr 25, 2006 7:51 pm 
Newbie

Joined: Fri Jan 27, 2006 1:48 am
Posts: 9
Deleted object is “sporadically” contained in Result List even though Auto flush is set [or if explicit session.flush() is done before the session.find(). Any insights would be appreciated...

Hibernate version: 2.1
Mapping documents:
<class
name="com.elasticpath.commons.datatransfer.MerchantAttributeDTO"
table="tmerchantattributes"
lazy="false"
>

<id
name="uidPk"
type="java.lang.Integer"
column="UID_PK"
>
<generator class="native">
<param name="sequence"></param>
</generator>
</id>


<!-- Associations -->

<many-to-one
name="merchantCategoryTreeDTO"
class="com.elasticpath.commons.datatransfer.MerchantCategoryTreeDTO"
>
<column name="merchantCategoryTreeUID" />
</many-to-one>
<!-- uni-directional one-to-one association to Tattribute -->
<many-to-one
name="attributeDTO"
class="com.elasticpath.commons.datatransfer.AttributeDTO"
>
<column name="attributeUID" />
</many-to-one>

</class>





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

Code:
      try {
         Session session =  currentSession();      // opens session
         session.delete(merchantAttributeDTOobj);
         
      } catch (HibernateException e) {
         throw new EPSystemException(e);
      }
   }

commitTransaction()   // closes session


Session session = currentSession()  //opens session

result = session.find("from MerchantAttributeDTO);  //finds object [merchantAttributeDTOobj]



Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 10:27 pm 
Regular
Regular

Joined: Wed Jul 07, 2004 2:00 pm
Posts: 64
How about posting the SQL trace for the entire sample?


Top
 Profile  
 
 Post subject: SQL trace associated with problem
PostPosted: Wed Apr 26, 2006 6:55 pm 
Newbie

Joined: Fri Jan 27, 2006 1:48 am
Posts: 9
I added some code to capture the # of rows in the DB before and after the delete...9 out of 10 times this "delete" works correctly...However, as you see in this sample the row count is the same..
After the code is the SQL trace associated with this section...I have color code the relevant SQL...
I assume that I haven't cleaned up some references properly but I haven't the foggiest idea where [or how] to look...You assistance is greatly appreciated...
Code:
   
                  List list = merchantAttributeDAO.list();
                  System.out.print("PRE DELETE: SIZE OF LIST ");
                  System.out.println(list.size());      
                  list = null;

                  merchantAttributeDAO.delete(this.merchantAttributeDTO);
               }

            }
         
         }
         
         TransactionBO.commitTransaction();

         TransactionBO.beginTransaction();
         List list = merchantAttributeDAO.list();
         System.out.print("AFTER DELETE: SIZE OF LIST ");
         System.out.println(list.size());
         list = null;
         TransactionBO.commitTransaction();




SQL:

Hibernate: select merchantat0_.UID_PK as UID_PK, merchantat0_.merchantCategoryTreeUID as merchant2_, merchantat0_.attributeUID as attribut3_ from tmerchantattributes merchantat0_
PRE DELETE: SIZE OF LIST 5


Hibernate: delete from tmerchantattributes where UID_PK=?
Hibernate: select merchantat0_.UID_PK as UID_PK, merchantat0_.merchantCategoryTreeUID as merchant2_, merchantat0_.attributeUID as attribut3_ from tmerchantattributes merchantat0_
Hibernate: select objectattr0_.categoryUID as category6___, objectattr0_.UID_PK as UID_PK__, objectattr0_.UID_PK as UID_PK4_, objectattr0_.value as value4_, objectattr0_.currency as currency4_, objectattr0_.language as language4_, objectattr0_.country as country4_, objectattr0_.categoryUID as category6_4_, objectattr0_.attributeUID as attribut7_4_, attributed1_.UID_PK as UID_PK0_, attributed1_.attributeKey as attribut2_0_, attributed1_.name as name0_, attributed1_.deleted as deleted0_, attributed1_.pickListValue as pickList5_0_, attributed1_.required as required0_, attributed1_.visibility as visibility0_, attributed1_.readOnly as readOnly0_, attributed1_.validationPattern as validati9_0_, attributed1_.defaultValue as default10_0_, attributed1_.systemUsage as systemU11_0_, attributed1_.system1 as system10_, attributed1_.system2 as system20_, attributed1_.system3 as system30_, attributed1_.system4 as system40_, attributed1_.system5 as system50_, attributed1_.customer1 as customer10_, attributed1_.customer2 as customer20_, attributed1_.customer3 as customer30_, attributed1_.customer4 as customer40_, attributed1_.customer5 as customer50_, attributed1_.ordering as ordering0_, attributed1_.attributeTypeUID as attribu23_0_, attributed1_.attributeGroupUID as attribu24_0_, attributed1_.attributeDependencyUID as attribu25_0_, attributet2_.UID_PK as UID_PK1_, attributet2_.name as name1_, attributet2_.EPKey as EPKey1_, attributet2_.description as descript4_1_, attributeg3_.UID_PK as UID_PK2_, attributeg3_.name as name2_, attributeg3_.deleted as deleted2_, attributeg3_.type as type2_, attributed4_.UID_PK as UID_PK3_, attributed4_.name as name3_, attributed4_.description as descript3_3_ from tCategoryAttribute objectattr0_ left outer join tAttribute attributed1_ on objectattr0_.attributeUID=attributed1_.UID_PK left outer join tAttributeType attributet2_ on attributed1_.attributeTypeUID=attributet2_.UID_PK left outer join tAttributeGroup attributeg3_ on attributed1_.attributeGroupUID=attributeg3_.UID_PK left outer join tAttributeDependency attributed4_ on attributed1_.attributeDependencyUID=attributed4_.UID_PK where objectattr0_.categoryUID=?

Hibernate: select objectattr0_.manufacturerUID as manufact6___, objectattr0_.UID_PK as UID_PK__, objectattr0_.UID_PK as UID_PK4_, objectattr0_.value as value4_, objectattr0_.currency as currency4_, objectattr0_.language as language4_, objectattr0_.country as country4_, objectattr0_.manufacturerUID as manufact6_4_, objectattr0_.attributeUID as attribut7_4_, attributed1_.UID_PK as UID_PK0_, attributed1_.attributeKey as attribut2_0_, attributed1_.name as name0_, attributed1_.deleted as deleted0_, attributed1_.pickListValue as pickList5_0_, attributed1_.required as required0_, attributed1_.visibility as visibility0_, attributed1_.readOnly as readOnly0_, attributed1_.validationPattern as validati9_0_, attributed1_.defaultValue as default10_0_, attributed1_.systemUsage as systemU11_0_, attributed1_.system1 as system10_, attributed1_.system2 as system20_, attributed1_.system3 as system30_, attributed1_.system4 as system40_, attributed1_.system5 as system50_, attributed1_.customer1 as customer10_, attributed1_.customer2 as customer20_, attributed1_.customer3 as customer30_, attributed1_.customer4 as customer40_, attributed1_.customer5 as customer50_, attributed1_.ordering as ordering0_, attributed1_.attributeTypeUID as attribu23_0_, attributed1_.attributeGroupUID as attribu24_0_, attributed1_.attributeDependencyUID as attribu25_0_, attributet2_.UID_PK as UID_PK1_, attributet2_.name as name1_, attributet2_.EPKey as EPKey1_, attributet2_.description as descript4_1_, attributeg3_.UID_PK as UID_PK2_, attributeg3_.name as name2_, attributeg3_.deleted as deleted2_, attributeg3_.type as type2_, attributed4_.UID_PK as UID_PK3_, attributed4_.name as name3_, attributed4_.description as descript3_3_ from tManufacturerAttribute objectattr0_ left outer join tAttribute attributed1_ on objectattr0_.attributeUID=attributed1_.UID_PK left outer join tAttributeType attributet2_ on attributed1_.attributeTypeUID=attributet2_.UID_PK left outer join tAttributeGroup attributeg3_ on attributed1_.attributeGroupUID=attributeg3_.UID_PK left outer join tAttributeDependency attributed4_ on attributed1_.attributeDependencyUID=attributed4_.UID_PK where objectattr0_.manufacturerUID=?
AFTER DELETE: SIZE OF LIST 5


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