Solved

Could you please modify my program to insert multiple records

Posted on 2011-02-26
4
256 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
Question by:stmani2005
  • 2
4 Comments
 
LVL 8

Author Comment

by:stmani2005
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 8

Author Comment

by:stmani2005
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 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now