Note that there are some explanatory texts on larger screens.

plurals
  1. POinsert record using for loop with spring mvc + hibernate
    primarykey
    data
    text
    <p><strong>[Spring MVC + Hibernate]</strong> </p> <p><strong>@Controller</strong></p> <pre><code>@Controller public class COAMaintenanceController { protected static Logger log = Logger .getLogger(COAMaintenanceController.class); @Resource(name = "COAMaintenanceService") private COAMaintenanceService coaMaintenanceService; @RequestMapping(value = "/addCoaMaintenance", method = RequestMethod.POST) public @ResponseBody JsonResponse addCoaCategory(@RequestParam("mainAccount") long mainAccount, @RequestParam("subAccount") long subAccount, @RequestParam("accountName") String accountName, @RequestParam("coaCategoryId") long coaCategoryId, @RequestParam("postingType") int postingType, @RequestParam("typicalBalance") int typicalBalance, @RequestParam("isActive") int isActive) { Date sysdate = null; JsonResponse response = null; try { sysdate = new Date(); response = new JsonResponse(); COAMaintenanceModel coaMaintenanceModel = new COAMaintenanceModel( mainAccount, subAccount, accountName, coaCategoryId, postingType, typicalBalance, isActive, GetSessionValue.getSysUserId(), GetSessionValue.getSysUserIp(), sysdate, 0); coaMaintenanceService.AddCOAMaintenance(coaMaintenanceModel); response.setStatus("Success"); } catch (Exception ex) { log.error("Exception.." + ex); response.setStatus("Fail"); } return response; } } </code></pre> <p><strong>@Service</strong></p> <pre><code>@Service("COAMaintenanceService") @Transactional public class COAMaintenanceService { @Resource(name="sessionFactory") private SessionFactory sessionFactory; public void AddCOAMaintenance(COAMaintenanceModel obj) { Session session = sessionFactory.getCurrentSession(); session.save(obj); } } </code></pre> <p>In <strong>Controller</strong> I write loop to enter record more than one time, but the following is not working , it insert only one record.</p> <pre><code>for(int i=0; i&lt;50; i++){ coaMaintenanceService.AddCOAMaintenance(coaMaintenanceModel); } </code></pre> <p>How to enter the multiple records in the above scenerio!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload