Hibernate optimization
Session Control To avoid the overhead created by Session, you need to control the current behavior of the Session: Controlling the use of Threadlocal Creating the Session Creating and closing the SESSION SESSION Nothing Filter Transaction Control For Hibernate by three DAO operation Find Save Flush Find is not need to open a business, so you can consider whether you don't use transaction control for SaveorupDate. Using transaction is now done in the end of Filter, but there is no need in some action, frequent switching transactions may bring A certain system overhead current test uses and does not use the transaction to query the test results (according to ID query record 100 times time comparison) Do not open the transaction 421ms Open transaction 516ms transaction Switch is best limited to the method, can consider switching transactions in the service method When this problem session shutdown and transaction, Hibernate actively calls the Flush method to synchronize, so do not need to care for the Flush method in the current project, the use of JDBC transaction does not choose JTA as a transaction to achieve the right to abandon the current test server tomcat itself is just a web server, it does not support the benefits of jta hibernate configuration property information hibernate.transaction.factory_class net.sf.hibernate.transaction.JTATransactionFactory net.sf.hibernate.transaction.JDBCTransactionFactory jta the JTA provides the inter-Session Transaction management capabilities have left the selection space to make a single increase in selection. Unnewhere is not required to call session.BegIntransAction (). Method for multiple records to call the API UserTransaction UT = (NEW INITIALCONTEXT () .lookup ("java: comp / userTransaction)); ut.begin (); // ..... UT. Commit (); using the following manner, transaction control can also be achieved, but because Hibernate also calls the above API implementation, it is not recommended to use Transaction TX = session.begintransAction (); tx.commit (); You can consider the use of Spring's AOP implementation replace the current implementation in Tomcat