Solved

Could you please modify my program to insert multiple records

Posted on 2011-02-26
4
261 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse console opening separately 2 37
What browser will run Java? 7 124
learn programming 8 68
DTD and JAVA versions 1 29
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

756 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