【发布时间】:2015-09-24 11:57:09
【问题描述】:
我是 spring-mvc-hibernate 的初学者,我有一个控制器,它在我的 spring mvc 中有许多对 daoimpl 方法的调用,这些方法由 @Transactional 注释它是为每个方法进行往返还是只做一个?
代码如下:Hibernate 用于处理所有调用
CustomerEntity customerEntity = (CustomerEntity) customerService.getCustomerFromLeadId(id);
AddressEntity resAddressEntity = (AddressEntity) addressService.getResAddress(customerEntity.getSomeId());
AddressEntity offAddressEntity = (AddressEntity) addressService.getOffAddress(customerEntity.getSomeId());
List<KeyContactsEntity> listKeyContacts = keyContactService.getKeyContactOfClient(customerEntity.getSomeId());
List<PropertyEntity> listProperty = propertyService.getListOfProperty(customerEntity.getSomeId()) ;
customerDto = masterService.setEntityValues(customerDto,customerEntity,resAddressEntity,offAddressEntity,listKeyContacts,listProperty);
【问题讨论】:
-
往返?往返哪里?所有带注释的方法都会自然地开始(并完成)它们自己的事务。
-
事务不会神奇地将完全不同的查询组合成一个查询。
标签: java spring hibernate model-view-controller transactional