-->
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: HELP: Hibernate deletes my Set elements !!!!!
PostPosted: Mon Feb 23, 2004 12:37 pm 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Please, any help on my problem would be really appreciated:

When I add elements to a Set, Hibernate issues SQL deletes on flush, cause it thinks that I deleted previous elements. So on the DB we have only the last inserted element.

Envinroment:
    Hibernate 2.1.2
    JBoss 3.1.2
    Oracle 9.1.2


I was able to reproduce the code with these few lines:

Code:
   ProdottoBase pb = (ProdottoBase)HibernateSession.getSession().load(ProdottoBase.class,new Integer(31826));
   
   CondizioneStringa cbstringa = new CondizioneStringaImpl();
   cbstringa.setNome("test "+System.currentTimeMillis());
   cbstringa.setValStringa("test valore");
   
   pb.addCondizioneBaseAll(cbstringa);


and this is the a snapshot of the mapping file (cascade="save-update"):

Code:
           <joined-subclass name="ProdottoBase" lazy="true">
              <key column="genericParam" />
            <set    name="condizioniBaseAll"
                  table="prodottoBase2CondizioneBase"
                  lazy="true">
               <key column="base"/>
               <many-to-many class="CondizioneBaseImpl"
                          column="condizioneBase" />               
            </set>
           </joined-subclass>

_________________
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Most likely your add method is messed up.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 12:47 pm 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
I hope you are rite, but it's hard to mess this:

Code:
   public void addCondizioneBaseAll(CondizioneBase condizione)
   {
      getCondizioniBaseAll().add( condizione );
   }

_________________
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 12:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hm, that should definately work :) Is this really everything you are doing in your code? Check the Hibernate log will give you some hints probably.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 12:57 pm 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Yes, it's really everything I do, cause I was able to reproduce it with the few lines I posted. I was sure to solve it after I isolated, but really, it's from friday that I go mad.
Anyway, with threshold sets to "INFO", I can see ONLY these lines of log. As you can see, the first time all goes well, but from the second iteration, Hibernate start to delete the previously insterted element, and so on.....

Code:
2004-02-23 17:45:19,322 INFO  [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
2004-02-23 17:45:19,542 INFO  [STDOUT] Hibernate: insert into genericparam (nome, descrizione, dataInizioValidita, dataFineValidita, codice) values (?, ?, ?, ?, ?)
2004-02-23 17:45:19,542 INFO  [STDOUT] Hibernate: insert into CondizioneBase (tipo, base, nomeCondizione, genericParam) values (?, ?, ?, ?)
2004-02-23 17:45:19,552 INFO  [STDOUT] Hibernate: insert into CondizioneStringa (valStringa, genericParam) values (?, ?)
2004-02-23 17:45:19,592 INFO  [STDOUT] Hibernate: insert into prodottoBase2CondizioneBase (base, condizioneBase) values (?, ?)
2004-02-23 17:45:23,538 INFO  [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
2004-02-23 17:45:23,608 INFO  [STDOUT] Hibernate: insert into genericparam (nome, descrizione, dataInizioValidita, dataFineValidita, codice) values (?, ?, ?, ?, ?)
2004-02-23 17:45:23,618 INFO  [STDOUT] Hibernate: insert into CondizioneBase (tipo, base, nomeCondizione, genericParam) values (?, ?, ?, ?)
2004-02-23 17:45:23,618 INFO  [STDOUT] Hibernate: insert into CondizioneStringa (valStringa, genericParam) values (?, ?)
2004-02-23 17:45:23,638 INFO  [STDOUT] Hibernate: delete from prodottoBase2CondizioneBase where base=? and condizioneBase=?
2004-02-23 17:45:23,648 INFO  [STDOUT] Hibernate: insert into prodottoBase2CondizioneBase (base, condizioneBase) values (?, ?)

_________________
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 1:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hm, I really can't explain. Is this a bidirectional relationship? Probably raising the log level gives you some more clue.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 1:29 pm 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Quote:
Is this a bidirectional relationship?

It was, I deleted the other end to check if that was the problem.

Quote:
Probably raising the log level gives you some more clue.

It writes a lot, which level do you think is appropriate ?

_________________
Ciao.


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.