-->
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: [JSP] Problem update/insert
PostPosted: Thu Jun 19, 2008 9:12 am 
Newbie

Joined: Fri May 23, 2008 5:20 am
Posts: 11
Location: Minusio, Switzerland
Hi,
I have a problem when I update something with Hibernate ...
When I update an object in a List sometimes sees the new object, sometimes not, sometimes I see 2changes before... : S
Let me give you an example:

Utente has many Info_utente.

When I update a Info_utente a Utente do:

Code:
Session fac = HibernateUtil.currentSession();
fac.beginTransaction();

Info_utente info_utente = (Info_utente) fac.get(Info_utente.class, id);
  info_utente.setRisposta("test");
Utente utente = info_utente.getUtente();                       
fac.update(info_utente);
fac.update(utente);
fac.flush();
fac.getTransaction().commit();



Sorry for my bad english

_________________
- ianaz -

http://www.ianaz.ch


Last edited by ianaz on Thu Jun 19, 2008 9:36 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 9:31 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi ianaz,

After looking into ur code, i see you dont update any fields, you just retrieve and persist I'm not sure why you would like to do that...

You dont have to save two times, bring in one-to-one mapping between Utente and Info_utente.. By doing that if you save info_utente, Utente will be saved by hibernate...

ie.
Code:
Session fac = HibernateUtil.currentSession();
fac.beginTransaction();

Info_utente info_utente = (Info_utente) fac.get(Info_utente.class, id);
                       
Utente utente = info_utente.getUtente();                       
[color=red][b]utente.setXXX("some value");[/b][/color]
fac.update(info_utente);
fac.flush();
fac.getTransaction().commit();


Give us some more info to tackle your issue..

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 9:37 am 
Newbie

Joined: Fri May 23, 2008 5:20 am
Posts: 11
Location: Minusio, Switzerland
Thanks for your reply ramnath :)

I make the update but I've not writed in the post... now I've updated the post... Sorry...

Waiting for a help again...

_________________
- ianaz -

http://www.ianaz.ch


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 9:44 am 
Newbie

Joined: Fri May 23, 2008 5:20 am
Posts: 11
Location: Minusio, Switzerland
ramnath wrote:
You dont have to save two times, bring in one-to-one mapping between Utente and Info_utente.. By doing that if you save info_utente, Utente will be saved by hibernate...

Then I update only Info_utente?

_________________
- ianaz -

http://www.ianaz.ch


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.