通过JPA RESPOSITORY插入数据时出现空指针异常

时间:2017-05-04 13:38:17

标签: java hibernate spring-data-jpa

Model.java:

import lombok.Data;
@Entity
@Table(name = "CUSTOMER")
@Data
public class Model{
@Id
@Column(name = "UNIQ_ID")
private String uniqId;
@Column(name = "CUSTOMER_ID",insertable = false,updatable=false)
private String customerId;
@Column(name = "STATUS")
private String status;
@ManyToOne
@JoinColumn(name = "CUSTOMER_ID")
private Customer model;
}

ModelRepository.java

public interface ModelRepository extends JpaRepository<Model, 
String>,JpaSpecificationExecutor<Model> {
}

ModelService.java

@Inject
private ModelRepository modelRepo;
@Transactional
public void registerCustomermodel(Model modeldata) {
    modelRepo.save(modeldata);
}   
public static void main(String[] args)
{
    ModelService cs=new ModelService();
    Model model=new Model();
    model.setCustomerId("111000000373");
    model.setUniqId("117");
    model.setStatus("null");
    cs.registerCustomermodel(model);
}

我的所有数据源配置文件都很好,同时执行此im获取空指针异常。谁能解释一下可能的原因是什么?

0 个答案:

没有答案