[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

12/06/2008 at 02:31AM PST, ID: 23962756
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Delete, Insert, Update using EJB3.0 EntityManager of new Entity Instances along with existing Entity Instances

Asked by pvasha in Enterprise Java Beans (EJB)

Tags: JSF, JBoss SEAM, EJB3.0, Hibernate

Hi
we have done the following steps for updating the existing records into the database.
step:1 we have fetched  the entity object from the database. there would be some set of records.
step 2. we have created a new entity object populated data  by reading from corba service, in this new entity object there also would be set of records which might having same set of data or additional record or less records compared with the existing entity object.
step 3: Now we need to update the database with the a newly created entity object in such a manner that the existing record in the database has to be updated, new record which has to inserted added in the new entity object list, remove the record which is not in the new entity object list.



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
public ApplicationRO updateContractPartnerAnil(ApplicationStateDO applicationStateDO) {
		
		Query query;
		ApplicationRO applicationRO = new ApplicationRO();
		
		// Reading data from data base
		ApplicationState existingApplicationState;
		
		query = em.createNamedQuery("ApplicationState.FindByApplicationNo");
		query.setParameter("theApplicationNumber", applicationStateDO.getApplicationNumber());
		query.setParameter("theApplicationVersionSeqNumber", applicationStateDO.getApplicationVersionSeqNumber());
		
		existingApplicationState = (ApplicationState) query.getSingleResult();
		List<ContractPartnerApplicationState> existingCPASList = existingApplicationState.getContractPartnerApplicationStateList();
		
		//Reading data from corba		
		ApplicationState newApplicationState = (ApplicationState) PartnerApplicationMapper.mapApplicationStateDoToApplicationStateEntity(applicationStateDO);
		List<ContractPartnerApplicationState> newCPASList = newApplicationState.getContractPartnerApplicationStateList();
		
		//int existingSize = existingCPASList.size();
		. . . . . .
. . . . . .
for ( . . . .  ). . . .
. . . . . . 
	 	. . . . . .
		// we need to know how to compare and update the existing application state entity object list with the new application state object list and do the merge/remove/persist on the existing application object so that insert update and delete happens accordingly
		em.merge(existingApplicationState); ????
		
		. . . .  .. 
		
		return applicationRO;
	}
[+][-]12/07/08 01:22 AM, ID: 23115170

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Enterprise Java Beans (EJB)
Tags: JSF, JBoss SEAM, EJB3.0, Hibernate
Sign Up Now!
Solution Provided By: pvasha
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_2_20070628