| Joined: Sun Oct 09, 2005 3:38 am
 Posts: 3
 | 
				
					| Hi!
 I want to know if there is someway to set a many to one association type property at the client side(When the instance is
 
 detached) to a new reference when I know the id of the new object to be referred.
 
 
 If we take sample Auction Project example.
 
 
 public class Bid extends Persistent implements Serializable{
 private AuctionItem item;
 private float amount;
 private Date datetime;
 private User bidder;
 
 ......
 
 ......
 }
 
 
 
 public Bid getBid(Long bidId){
 
 Bid bid;
 
 // takes the session form Session factor
 // returns the bid
 // closes the session
 
 return bid; (This instance will be detached when it is tranferred to the client side while serialization)
 }
 
 
 public void saveBid(Bid bid){
 // takes the session form Session factor
 // Merge the bid object
 // commit changes and closes the session
 }
 
 
 
 //Method at the clientside
 public void updateBid() throws Exception {
 
 Bid bid = auctionFacade.getBid(new Long(1));  //fetches the detached instance of Bid from Server Side
 
 /* I want to update the Bidder of the Bid to a different User Instance whose ID is known.
 (I understand that it does not make much business sense to update the bidder of the bid,
 but I have a genuine case where I want to update the association between 2 objects in
 exactly similar case).*/
 
 /* The only way I can think of is getting the user instance from server as follows*/
 
 User newUser=AuctionFacade.getUser(userId);
 
 Bid.setUser(newUser);
 
 /* this is not acceptable to me since it requires a server round trip. My client is actually
 on a wan and I can not afford the performance loss due to this. I need to do something where I
 can create a Proxy type thing of the user instance just on the basis of the userid.*/
 
 bid.setUser(??) // What can I do here?
 
 auctionFacade.saveBid(bid);
 
 }
 
 
 
 I hope the above explains my problem. Thanks in advance for the solution.
 
 
 |  |