-->
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: best way to generate IDs in a J2EE client-server app
PostPosted: Tue Feb 24, 2004 10:36 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi All,

Having a fairly complex object graph and a J2EE client-server with Hibernate coupled only to the J2EE server; the DTOs are passed in the RMI (session bean) calls.

The problem is that if I want to change some collection for say, object A and call via RMI the session bean then somehow I need to pass back to the client (as return object(s)) the modified IDs, in case I added a new member to the collection. Otherwise my client will not operate properly on the newly changed collection of A.

I can return the entire container for the collection but this is expensive. Or, I can just return the changed IDs, but this is quite cumbersome.

Another way would be to assign IDs on the client side, but we would go with auto-generated IDs.

Please advice.

TIA,

--steve p.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 1:13 am 
Beginner
Beginner

Joined: Sun Oct 26, 2003 11:21 pm
Posts: 27
You're talking about two steps:

    create new entity and assign ID
    add entity to collection


You could create and add the new entities first (have a special session bean, just to add new entities, that returns the the entities with IDs filled in).

Then add them to the collection. Once they're added, they've already got their ID's and they behave properly.

You would need to start the transaction on the client to make all this happen atomically, but that's not too hard.


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.