@Test public void testManyToOneSave() { //双向关联关系 Customer customer = new Customer("ccccccccccccccc"); Order order1 = new Order(); order1.setOrderName("order 1111111111"); Order order2 = new Order(); order2.setOrderName("order 2222222222"); order1.setCustomer(customer); order2.setCustomer(customer);
Hibernate: insert into atguigu.hb_order (hb_order_name, customer_id) values (?, ?) Hibernate: insert into atguigu.hb_order (hb_order_name, customer_id) values (?, ?) Hibernate: insert into atguigu.hb_customer(hb_customer_name) values(?) =destroy= Hibernate: update atguigu.hb_order set hb_order_name=?, customer_id=? where hb_order_id=? Hibernate: update atguigu.hb_order set hb_order_name=?, customer_id=? where hb_order_id=? Hibernate: update atguigu.hb_order set customer_id=? where hb_order_id=? Hibernate: update atguigu.hb_order set customer_id=? where hb_order_id=?
Hibernate: select customer0_.hb_customer_id as hb1_2_0_, customer0_.hb_customer_name as hb2_2_0_ from atguigu.hb_customer customer0_ where customer0_.hb_customer_id=? Customer{customerId=1, customerName='bbbbbbbbbbbbbbbb'} class org.hibernate.collection.internal.PersistentSet
Hibernate: select customer0_.hb_customer_id as hb1_2_0_, customer0_.hb_customer_name as hb2_2_0_ from atguigu.hb_customer customer0_ where customer0_.hb_customer_id=? Hibernate: select orders0_.customer_id as customer3_2_1_, orders0_.hb_order_id as hb1_1_, orders0_.hb_order_id as hb1_3_0_, orders0_.hb_order_name as hb2_3_0_, orders0_.customer_id as customer3_3_0_ from atguigu.hb_order orders0_ where orders0_.customer_id=? =destroy= Hibernate: update atguigu.hb_order set hb_order_name=?, customer_id=? where hb_order_id=?
Hibernate: select order0_.hb_order_id as hb1_3_0_, order0_.hb_order_name as hb2_3_0_, order0_.customer_id as customer3_3_0_ from atguigu.hb_order order0_ where order0_.hb_order_id=?