/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.euroccp.tps.entities.facade; import com.euroccp.tps.entities.mapping.Instructions; import com.euroccp.tps.entities.mapping.InstructionsInterface; import com.mysql.clusterj.Session; import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import javax.persistence.EntityManager; /** * * @author Administrator */ public class InstructionsFacade { public void updateRecordClusterJ(Session session, int id, BigDecimal amount) throws Exception { InstructionsInterface instructionsInterface = session.find(InstructionsInterface.class, id); if (instructionsInterface == null) { //Insert instructionsInterface = session.newInstance(InstructionsInterface.class); instructionsInterface.setId(id); instructionsInterface.setTotal(amount); session.persist(instructionsInterface); } else { //Update instructionsInterface.setTotal(instructionsInterface.getTotal().add(amount)); session.updatePersistent(instructionsInterface); } } }