-->
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.  [ 1 post ] 
Author Message
 Post subject: Best Approach
PostPosted: Mon May 31, 2010 3:38 pm 
Newbie

Joined: Thu May 27, 2010 10:48 am
Posts: 10
Hey guys, what would be the best approach for this process:

public class Customer {
private List<Car> carList;
...
}

public class Car {
private String name;
..
}

So have an example
Peter bought a ferrari,

Customer peter = new Customer();
Car ferrari = new Car();
car.setName("ferrari")
peter.addCar(ferrari);
...
(call DB) session.save(peter)

unfortunately he did not like the car (Are u nuts, peter?)
so he sold it to Jack. What is the best way to do it?

I could do like:
ferrari = getFerrari();

jack = getCustomer();
jack.removeCar(ferrari);
(call DB) alterCustomer(jack)

* I just get Jack, remove the car and save it again.

Customer jack = new Customer();
jack.addCar(ferrari);
(call DB) session.save(jack)

* and I finally add the same Ferrari to Jack's object and save it.

Is there a easier or better way to do that?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.