Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Could you please modify my program to insert multiple records

Posted on 2011-02-26
4
Medium Priority
?
266 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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

916 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