-->
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: Deleting objects
PostPosted: Wed Apr 14, 2004 9:39 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Code:
         HibernateUtil.delete(this);
         log.debug("ID:" + this.getId());
         log.debug("Contains:" + getUser().getPhones().contains(this));
         log.debug("Equals:" + getUser().getPhones().iterator().next()
               .equals(this));
         log.debug("Phone removed: " + getUser().getPhones().remove(this));


Code:
2004-04-14 17:33:50,388 DEBUG bl.DPUserPhoneHBImpl - ID:63
2004-04-14 17:33:50,388 DEBUG bl.DPUserPhoneHBImpl - Contains:false
2004-04-14 17:33:50,388 DEBUG bl.DPUserPhoneHBImpl - Equals:true
2004-04-14 17:33:50,388 DEBUG bl.DPUserPhoneHBImpl - Phone removed: false
Hibernate: delete from DP_USER_PHONES where ID=?

Code:
   public static void delete(Object obj) throws HibernateException
   {
      try
      {
         Session session = HibernateUtil.currentSession();
            session.delete(obj);
      }
      catch (HibernateException e)
      {
         throw e;
      }

   }

What's wrong? Why can't I remove object from the colection?
What must becode with object's ID after deleting object?[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 9:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you forgot to post your mapping files


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 9:49 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Code:
    <class name="DPUserHBImpl" table="DP_USERS" lazy="true" >
        <!-- A 32 hex character is our surrogate key. It's automatically
            generated by Hibernate with the UUID pattern. -->
        <id name="id" type="string" unsaved-value="null" >
            <column name="ID" sql-type="number" not-null="true"/>
           <generator class="com.amfitel.common.hb.StringSequenceGenerator">
              <param name="sequence" >DP_USERS_SEQ</param>
          </generator>
        </id>
       <property name="name" type="string" column="LOGIN" />
       <property name="password" type="string" column="PASS" />

       <property name="surname" type="string" column="SURNAME" />
       <property name="firstname" type="string" column="FIRSTNAME" />
       <property name="lastname" type="string" column="LASTNAME" />
       <property name="birthdate" type="date" column="BIRTHDATE" />
      <set name="groups" lazy="true"  order-by="ID" inverse="true" >
           <key column="MODULE_VERSION_ID"/>
         <one-to-many class="DPRevisionHBImpl" />
      </set>
      <set name="mails" lazy="true"  inverse="true" >
           <key column="USER_ID"/>
         <one-to-many class="DPUserMailHBImpl" />
      </set>
      <set name="phones" lazy="true"  inverse="true" >
           <key column="USER_ID"/>
         <one-to-many class="DPUserPhoneHBImpl" />
      </set>
    </class>
    <class name="DPUserPhoneHBImpl" table="DP_USER_PHONES" lazy="true" >
        <id name="id" type="string" unsaved-value="null" >
            <column name="ID" sql-type="number" not-null="true"/>
           <generator class="com.amfitel.common.hb.StringSequenceGenerator">
              <param name="sequence" >DP_USER_PHONES_SEQ</param>
          </generator>
        </id>
       <property name="phone" type="string" />
       <property name="remm" type="string" />
      <many-to-one name="type" column="TYPE_ID" not-null="true" class="DPUserPhoneTypeHBImpl" />
      <many-to-one name="user" column="USER_ID" not-null="true" class="DPUserHBImpl" />
    </class>


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.