Spring+struts2/hibernate Study Notes

Source: Internet
Author: User

========= Automatic Assembly =========

Autowire-Specify automatic assembly policy
ByName if it is a ByName automatic assembly strategy, spring will be responsible for the setter method name corresponding to
The bean Injection
If not found, no injection is performed (that is, the setter method is not called)
Bytypespring will be responsible for injecting the bean with the container type as the setter method parameter type.
If not found, no injection is performed (that is, the setter method is not called)
If more than one bean is found, an error is made and an exception occurs.

Autowire-candidate-true/false. If False, indicates that it is not a candidate for automatic assembly

=====================spring and hibernate=======================

Integration of Spring and hibernate
1. Configure the Sessionfactory,spring container directly in the configuration file responsible for managing the Sessionfactory
Spring containers can be sessionfactory injected into other components
2. Effective Session Management
3. Declarative transaction Management
4. Uniform Exception Packaging

Spring provides a class for simplifying hibernate operations: hibernatetemplate

Façade mode: In fact, we should just pass in Hq1, Val1, Val2, Val3 ... The program should return the query results.
Spring's hibernatetemplate implements this façade pattern:
-List Find (HQL)
-List Find (String querystring,object ... values)
-List Find (hql,object value)

-Get (string entityname,serializable ID)/load (string entityname,serializable ID)
-Delete (Object entity)
-Save (object entity)/persist (object entity)
-Update/saveorupdate (Object entity)
/******************************************
In the original Hibernate query:
Session sess=sf.opensession ()
Transaction tx=sess.begintranasction ();
Query query=sess.creatquery ("from ...");
Query.setparameter (VAL1);
Query.setparameter (VAL2);
Query.setparameter (VAL3);
Query.list ();

If you are using the traditional hibernate programming pattern, you need to sequentially and sequentially call the 3 API methods.
******************************************/

Spring provides a class for simplifying hibernate operations: hibernatetemplate
Mainly for hibernatetemplate to pass in a sessionfactory, the next most persistent operation as long as one line of code can be done.

Spring+struts2/hibernate Study Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.