This article is an entry-level article for spring-based Web application development. The front-end adopts the struts MVC Framework, the middle layer adopts spring, and the backend uses hibernate.
This article includes the following content:
· Configure Hibernate and transactions
· Load the
Configuration instructions for developing web programs using spring and Hibernate and detailed descriptions of simple instances
Author: YanekEmail: yanek@126.com
I. Goals:
Use spring and Hibernate to add a user. Add User information to the databaseUse the hibernate template
(From: Beginning Hibernate and spring-framework-3.0.5.RELEASE reference)
In the spring and hibernate integration framework, session factory is configured as a springBean. in earlier versions, the hibernatedaosupport and hibernatetemplate classes are used. methods can be directly used in the new version.The getcurrentse
, the sample code is as follows:
@Repositorypublic interface UserRepository extends JpaRepository2. The implementation class does not need to be explicitly implemented UserRepository , as long as it is named UserRepositoryImpl .The advantage is that there is no need to rewrite a method that does not require writing SQL or SQL statements that are not complex (using @Query annotations can be implemented).For methods that need to be judged and spliced into query conditions, we can override the
, setting Springtransactionsynchronizationmanager.initsynchronization (). It is only after this operation that we can later hibernate save or update, Allows hibernate callback to be initialized when the Spring springsessioncontext generates hibernatesession and further gets jdbcconnection from the connection pool//Create "Empty" Transaction:no actualtransaction,
Original address: http://lengyun3566.iteye.com/blog/1068998
Recently read "Spring Security3" a book, quite rewarding (see picture on the cover). Therefore, some of its content is translated into Chinese, for the electronic version of the content, I give up all rights.
Before the translation, I have sent an e-mail to consult the original author's opinion, is now half a month, have not seen his reply.
The previous blog has explained several common methods for configuring data sources in spring. Next, I will continue to explain this blog. After configuring the data source, how does the DaO layer access the database?
Based on the recent project using the SSH2 framework, this paper analyzes and summarizes the two common methods for accessing the database at the DaO layer after spring and
(i) Integration of spring and hibernate frameworks
key points of integration:
(1) The data source is configured in the spring configuration file for use by the spring and hibernate frameworks;
(2) The Hibernate.hbm.xml configuration file is no longer needed, and the
• Definition: Java Three frameworks are mainly used for Wen applications. Struts is mainly responsible for the display of the presentation layer;Spring uses its IOC and AOP to handle the control business (responsible for the operation of the database);hibernate is primarily data persistence to the database. (1) Struts framework: Struts is open source software. The purpose of using struts is to help us reduc
Configure hibernate + spring in myeclipse (FAST)
Keywords: Configure hibernate + spring in myeclipse Popular Development Mode: Spring + hibernate + Struts. Here I will introduce the combination of
Spring hibernate configuration conflict in AOP
Spring2.0 hibernate3.1.x/hibernate3.2
When you use spring's AOP programming, you use these several lib:
Asm-2.2.2.jar
Asm-commons-2.2.2.jar
Asm-util-2.2.2.jar
Hibernate If you use Lib:
Asm.jar
Asm-attrs.jar
where Asm-2.2.2.jar and Asm.jar exist class conflicts ...
Using one or both of these, you may receive the
Long long ago. I've heard about SSH. At first, I thought it was a thing, the details are unknown, always think high-end atmosphere on the grade, after learning to find, not only tall, but also a low-key luxury has connotation, after a period of research and learning SSH framework basic principles and ideas. Finally grounded the gas. As the beginning of learning, a little bit of harvest, want to blog in the form of sharing with everyone, common progress, in the process of updating the blog will i
Before we talk about spring transaction management, let's think about how we do data manipulation in hibernate when we're not using spring. In Hibernate we do one operation at a time we have to open the transaction, then the data operation, and then commit the transaction, close the transaction, we do this because
interview of Struts,spring,hibernate three frames1.Hibernate working principle and why use? Principle: 1. Read and parse the configuration file 2. Read and parse the mapping information, create Sessionfactory 3. Open Session 4. Create transaction transation 5. Persist Operation 6. COMMIT TRANSACTION 7. Close Session 8.Why to turn off Sesstionfactory: 1.The code f
Quick Start
This article is a primer for developing Web applications based on spring, using the Struts MVC framework, the middle tier using spring, and the background using hibernate.
This article contains the following elements:
• Configure Hibernate and transactions
• Load Spring's applicationcontext
) {Resume (null, suspendedresources);throw ex;}Catch (Error Err) {Resume (null, suspendedresources);throw err;}}Else {Note 3 This process is the path that is executed when there is no transaction in the thread and the configuration is propagation= propagation.supports. This step does not generate Hibernate Session, JDBC Connection. But Preparetransactionstatus() Does a step, setting springtransactionsynchronizationmanager.initsynchronization (). It i
Label: Spring bundle Hibernate. Clip: One 1. What does Spring do with Propagation=propagation.supports? 2. When does Spring generate hibernatesession? 3. What are the effects, similarities and differences between Propagation=propagation.supports and Propagation=propagation.require on the generation session? 3.1. What
For the SSH framework, the core is spring.
1Struts is only responsible for intercepting requests on the browser side (which can be understood to get request requests, that is, to get the request object.) The Request object contains information such as the form information that the user entered on the page , the currently logged on user , and so on, and maps the requests to the execution class. All the rest of the work is given to
How does hibernate work and why should I use it?Principle:1. Read and parse the configuration file2. Read and parse mapping information, create Sessionfactory3. Open Sesssion4. Create Transaction Transation5. Persistent operation6. Commit a transaction7. Close session8. Close SesstionfactoryWhy to use:1. The code for JDBC access to the database is encapsulated, which greatly simplifies the tedious repetitive code of the data access layer.2.
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.