T1中Set设置了 inverse="true" cascade="save-update"
T1 t1 = new T1();
T2 t2 = new T2();
t2.setT1(t1);
Set t2s = new HashSet();
t2s.add(t2);
t1.setT2(t2s);
sessoin.save(t1);
代码有点乱~~~~
为什么在保存主表时出现了三条SQL语句
一条查询,两条插入
1.为什么会多出一条查询语句?(最好详细点,不太明白)
2.如何去掉多出的一条查询语句?
等待前辈解答
Country country = new Country();
country.setId(10);
country.setName("a");
Province province1 = new Province();
province1.setId(101);
province1.setName("a1");
province1.setCountry(country);