-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to add one element to collection without loading?
PostPosted: Thu Jun 28, 2007 4:16 pm 
Regular
Regular

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

Lets say i have - Department
Department has a List of Emploee (@OneToMany).

I want to add one emploee to the list withot loading the whole collection.

department.getEmployee().add(emploee)
will load the collection and it is bad if i have a big collection.


Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 7:00 pm 
Newbie

Joined: Thu Nov 09, 2006 9:42 pm
Posts: 13
Try something like this:

Code:
List<Employee> employees= new ArrayList<Employee>();
employees.add( employee);
department.setEmployee( employees);
entityManager.merge( department);

--
Tim


Top
 Profile  
 
 Post subject: The use case that i am talking about is adding elment
PostPosted: Thu Jun 28, 2007 8:54 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
to already persistenced large collection.


you already have Department which has reference to list of employee

so you need :
Quote:
Deprtment dep = em.find(Department.class,ID);
dep.getEployeeList.add(Employee);


This will load the complete list.

Also i want to avoid bi-directional if i dont have to.

Thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.