hibernate 中删除含有父对象的对象

public class Person{
private String id;
private Person parent;
}

Person persion = new Person();
// 1
Person parent = new Person();
parent.setId("1111111111");

//2
Person parent = findById("1111111111");
person.setParent(parent);

delet(person);


注释中的1和2,比较一下,貌似1的速度更快一下,不知道是否有什么问题。。。。
通常采用的是2.

//2

Person parent = findById("1111111111");

那是因为这个调用了findById方法,应该是去数据库查询的操作吧,自然是比直接的方法调用(parent.setId("1111111111"); )要慢多了

朋友,问题要自动关闭啦,结分哦,