-->
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: set many to one property at the client side
PostPosted: Fri Oct 14, 2005 5:44 am 
Newbie

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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:12 am 
Newbie

Joined: Sun Oct 09, 2005 3:38 am
Posts: 3
Hi!

Am I talking about something very silly or impossible.Please do give some commets on the issue.

Thanks


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.