-->
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.  [ 2 posts ] 
Author Message
 Post subject: Is my code OK?
PostPosted: Fri Jan 14, 2005 4:28 pm 
Newbie

Joined: Thu Jan 13, 2005 11:41 am
Posts: 3
Hi,

I have worked out a piece of code. But I'm not 100% sure if this is the way to do it. But it works....

I have a class parameter that contains a collection of parameterdetails. And I want to update on of the parameterdetails, out of the collection.

long pk = 50;

Parameter parameter = new Parameter();
session.load(parameter,new Long(pk));

Collection query = getSession().filter(parameter.getParameterDetails(),"where this.id = "+ parameterForm.getId());
if(!query.isEmpty()){ //I'm 1000% sure that the object exists, but I couldn't remove the if, bad feelings....
Parameterdetail parameterDetail = (Parameterdetail)query.iterator().next();
ParameterdetailLogic.setData( parameterDetail,
parameterForm.getOmschrijvingNL(),
parameterForm.getOmschrijvingFR(),
parameterForm.getOmschrijvingEN(),
parameterForm.getOmschrijvingDE());
getSession().saveOrUpdate(parameterDetail);
}

Thx in advance,
Pieter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2005 1:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Why don't you just load and update the Parameterdetail object, you have its id.


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