Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Could you please modify my program to insert multiple records

Posted on 2011-02-26
4
Medium Priority
?
265 Views
Last Modified: 2012-08-13
could you please modify my program to insert multiple records in Databas

could you please give me the code to insert multiple records using for loop,list and input DTO from junit test case          

 public  void testAdd() {
           System.out.println("testAdd");
                CustomBillerDTO inputDTO = new CustomBillerDTO();
                CustomBillerListDTO outputDTO = new CustomBillerListDTO();
                CustomBillerListDTO outputListDTO = new CustomBillerListDTO();
                List<CustomBillerDTO> arrInputList=new ArrayList<CustomBillerDTO>();
                AuditDTO auditDTO=new AuditDTO();
               // inputDTO.setLegalVehicleCode("LV17");
                inputDTO.setBillerCode("NSEL18");
                inputDTO.setBillUpLoadType("Y");
                inputDTO.setPayPressFlag("1");                
                auditDTO.setActiveStatusFlag("AA");                          
                auditDTO.setMakerCode("M");
                auditDTO.setCheckerCode("C");
                auditDTO.setWorkBranchCode("133");
                auditDTO.setChannelSource("1"); //ACC_CHA
                auditDTO.setMakerRemarks("MRE"); //ACC_MAKER
                auditDTO.setCheckerRemarks("CRE"); //ACC_CHEC
                inputDTO.setCurrentActiveStatusFlag("A");                      
                inputDTO.setAuditDTO(auditDTO);
                arrInputList.add(inputDTO);
                outputListDTO.setList(arrInputList);
                outputDTO=target.add(outputListDTO);
                System.out.println("Added");
                               }
            }

   
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 34986294
above code to insert only one reocrd

give me the code to insert multiple records
0
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 34990355

Which sentence inserts the object into database? I cant find it, please expalin.

And what does JUnit have to do with all of this?
0
 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 34994231
this code is insert the data into database

outputDTO=target.add(outputListDTO);
                System.out.println("Added");
0
 
LVL 3

Accepted Solution

by:
mehdi_javan earned 2000 total points
ID: 34994718
It seems the following code is what you want:
public  void testAdd() {
	System.out.println("testAdd");
	CustomBillerListDTO outputDTO = new CustomBillerListDTO();
	CustomBillerListDTO outputListDTO = new CustomBillerListDTO();
	List<CustomBillerDTO> arrInputList=new ArrayList<CustomBillerDTO>();
	for(int i = 0; i < 10; i++) {
		CustomBillerDTO inputDTO = new CustomBillerDTO();
		AuditDTO auditDTO = new AuditDTO();
	   // inputDTO.setLegalVehicleCode("LV17");
		inputDTO.setBillerCode("NSEL18");
		inputDTO.setBillUpLoadType("Y");
		inputDTO.setPayPressFlag("1");                
		auditDTO.setActiveStatusFlag("AA");                          
		auditDTO.setMakerCode("M");
		auditDTO.setCheckerCode("C");
		auditDTO.setWorkBranchCode("133");
		auditDTO.setChannelSource("1"); //ACC_CHA
		auditDTO.setMakerRemarks("MRE"); //ACC_MAKER
		auditDTO.setCheckerRemarks("CRE"); //ACC_CHEC
		inputDTO.setCurrentActiveStatusFlag("A");                      
		inputDTO.setAuditDTO(auditDTO);
		arrInputList.add(inputDTO);
	}
	outputListDTO.setList(arrInputList);
	outputDTO=target.add(outputListDTO);
	System.out.println("Added");
}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question