spring Boot+JPA呼び出し格納プロセス

11898 ワード

本明細書で呼び出した格納プロセスは、状況によってはすべての人に適用されないかもしれない。ここでは私が出会った状況について、自分で測ってみます。出会った仲間は試してみてもいいです。
1、まずエンティティクラスにおいて、格納プロセスとの関連を確立する。

@Entity
 
/**
 *  @Procedure        
 *          @NamedStoredProcedureQuery       JPA 。
 * procedureName            
 * name JPA        
 *     @StoredProcedureParameter          IN/OU  
 */
 
@NamedStoredProcedureQuery(name = "ucbe",procedureName = "P_UNIFIED_CREDIT_BATCH_ETL",parameters = {
        @StoredProcedureParameter(mode = ParameterMode.IN,name = "fileName",type=String.class),
        @StoredProcedureParameter(mode = ParameterMode.IN,name="linkId",type = String.class)
})
@Table(name="UNIFIED_CREDIT_BATCH_TRA")
public class UnifiedCreditBatchTraPo  {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator="UC_SEQ_BATCH_TRA")//  oracle    
    @SequenceGenerator(name="UC_SEQ_BATCH_TRA",sequenceName="UC_SEQ_BATCH_TRA",allocationSize="1")
    @Column(name="ID")
    private Integer id;
 	
 	@Column(name="CUSTOMERID")
    private String customerId;
 
	@Column(name="LINKID")
    private String linkId;

	@Column(name="FILENAME")
    private String fileName;
 
    public Integer getId() {
        return id;
    }
 
    public void setId(Integer id) {
        this.id = id;
    }
 
    public String getCustomerId() {
        return customerId;
    }
 
    public void setCustomerId(String customerId) {
        this.customerId= customerId;
    }
 
    public String getLinkId() {
        return linkId;
    }
 
    public void setLinkId(String linkId) {
        this.linkId= linkId;
    }

	public String getFileName() {
        return fileName;
    }
 
    public void setFileName(String fileName) {
        this.fileName= fileName;
    }
}
2、dao層呼び出し格納プロセス
public interface UnifiedCreditBatchTraDao extends JpaRepository<UnifiedCreditBatchTraPo,String>{
   /**
     *       
     * pluslinout       
     * @param arg
     * @return
     */
    @Procedure(procedureName = "P_UNIFIED_CREDIT_BATCH_ETL")
    void unifiedCreditBatchEtl(String fileName,String linkId);
}
3、制御層呼び出しのdao層方法
@RestController
public class UnifiedCreditController {
    @Autowired
    private UnifiedCreditBatchTraDao unifiedCreditBatchTraDao;
 
  
    /**
     * @Procedure
     *       
     */
    @RequestMapping("doProcedure")
    public void doProcedure(String fileName,String linkId){
		try{
			unifiedCreditBatchTraDao.unifiedCreditBatchEtl(fileName,linkId);
		}catch{
			logger.error("        ",e)
		}       
    }
}
: , 。 , @StoredProcedureParameter(mode = ParameterMode.OUT,name="res",type = Integer.class) 。 dao 。