-->
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: Design :: How to expose API for adding new object to a list
PostPosted: Fri May 11, 2007 7:22 am 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
Hey,

I have a swt client and a stateless facade that expose the server API to the client.

Suppose that I have two objects - Company the contain list of workers

I want to write a generic API to the client that create,add,update,delete objects.

Some objects, like worker need to be created in a parent context.
I mean that in order to create new worker we need to have the company that the worker belongs.
So, I thought about the following API:

Code:
Object public createObj(parentId,parentType,obj);

The function will add the worker to the list of workers in company and will return the new Worker object (with the ID).

There are some issues here:
1. In order to save the new worker I need to get the workers list in company than add the new worker and save the company.
The problem is that in case that there are thousands of workers we will need to load all the workers for only save one worker.
2. hibernate required to save the company object in order to save the worker (there are OneToMany), so the persist return Company object but i want to return to the client the new Worker that has been created.
I don't want to run on all the thousands of workers in order to search this worker.

How you overcome the problem that I mention above?

Thank you


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.