使用crudrepository节省实体需要花费太多时间

时间:2014-10-10 10:10:40

标签: java spring

我正在尝试使用crudrepository更新数据库中的条目,但每次迭代需要大约24秒。下面是代码。提前谢谢。

for(tmp.request.Number numb : Num_list){
            EnterpriseVnumbList addNumb = entNumbdao.findByVnumbmsisdnAndEnterpriseid(numb.getNumber(), frmEntp);

            if(addNumb != null){

                addNumb.setEnterpriseId(toEntp);                     // toEnt is a class Enterprise
                entNumbdao.save(addNumb); // entNumbdao is EnterpriseVnumbListRepo 
                addEntpToEnt++;
            }else{
                log.error("NumbProcessing: Failed to");              
            }     

这是我的EnterpriseVnumbList类

@Entity
@Table(name = "enterprise_vnumb_list", uniqueConstraints = {
        @UniqueConstraint(columnNames = {"vnumb_msisdn"})})
@XmlRootElement
public class EnterpriseVnumbList implements Serializable {
    @Size(max = 10)
    @Column(name = "parent_id")
    private String parentId;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "vnumb_msisdn", nullable = false, length = 30)
    private String vnumbmsisdn;
    @Size(max = 30)
    @Column(name = "imsi", length = 30)
    private String imsi;
    @Column(name = "assigned")
    private Boolean assigned;
    @Size(max = 30)
    @Column(name = "assigned_to_sim", length = 30)
    private String assignedtosim;
    @JoinColumn(name = "enterprise_id", referencedColumnName = "enterprise_id", nullable = false)
    @ManyToOne(optional = false)
    private Enterprise enterpriseid;
/// Some code here
}

//这是EnterpriseVnumbListRepo类

@RepositoryDefinition(domainClass=EnterpriseVnumbList.class, idClass=Integer.class)    
public interface EnterpriseVnumbListRepo extends CrudRepository<EnterpriseVnumbList, Integer>, JpaSpecificationExecutor<EnterpriseVnumbList>{
    EnterpriseVnumbList findByVnumbmsisdnAndEnterpriseidAndAssigned(String vsim, Enterprise enterpriseid, boolean assgn);
    EnterpriseVnumbList findByVnumbmsisdnAndEnterpriseid(String vsim, Enterprise enterpriseid);
    List<EnterpriseVnumbList> findByEnterpriseidAndAssigned(Enterprise entp, boolean assgn);
    EnterpriseVnumbList findByVnumbmsisdnAndAssignedtosim(String vsim, String sim);
    EnterpriseVnumbList findByVnumbmsisdnAndEnterpriseidAndAssignedNot(String vsim, Enterprise enterpriseid, boolean assgn);
    Long countByEnterpriseidAndAssigned(Enterprise entp, boolean assgn);
    Long countByEnterpriseid(Enterprise entp);
} 

0 个答案:

没有答案