JPA一对多保存维护端时,报被维护端属性为空异常
表A
@ManyToOne
private B b;
表B
@Column(length = 10, nullable = false, unique = true)
private String name;
@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "b")
private Set
alist;
Service(已加入@Service和@Transactional)
A a = new A();
a.setB(new B(1));
service.save(a);
这时报错:
not-null property references a null or transient value : com.entity.B.name
可是我在JUnit里面用同样的确可以 ,这是怎么回事啊
spring-mvc spring hibernate jpa
初夜给了谁、
10 years, 2 months ago