Today, with Maven, the Struts2, spring, hibernate integration is implemented.There were a lot of mistakes in the middle. Most of these are caused by an error in the configuration file. To integrate here:Note: Here we implement a login function. The user enters the user name and password from the JSP page, the server verifies its correctness, jumps to the different page according to the correct or not.First,
based on Spring+hibernate the realization method of checking and deleting general additions and deletions
Wang Pao
Msn:baozhengw999@hotmail.com
qq:29803446
First, the design plan
1.1 Name Words explain:
Business Service layer: The Business Service layer references the Data Access Layer interface DAO, the class name of the business service layer is generally the suffix of service
(such as requestcontextholder, transactionsynchronizationmanager, and localecontextholder), making them thread-safe, because stateful beans can be shared in multiple threads.
Generally, web applications are divided into three layers: presentation layer, service layer, and persistence layer. The corresponding logic is written in different layers. The lower layer opens function calls through interfaces to the upper layer. In general, all program calls from receiving a request to returning a respo
;generate persistence mapping->by Database Schema6. Select the table you want to generate class and HBM, for example we only select one hellotable7. After the generation is like this, when you want the console to hibernate hql query, he will error, (Do not know why ...) Knowing that the deploy succeeds, the query is normal again)8. We need to modify the location of the Hibernate.cfg.xml file and the locatio
1.Spring Integrated Hibernate(1) Introduction of the development packageA. Spring Basic package: Spring.jar,commons-logging.jarB. Spring AOP Package: Aspectjrt.jar,aspectjweaver.jar,cglib-nodep-2.1_3.jarC. Database driver package: Mysql-connector-java-5.1.6-bin.jarD. Connection Pool Package: Commons-dbcp.jar,commons-po
Struts + spring + hibernate
This configuration environment: myeclipse5.5, Mysql5.0,Struts1.2,Spring2.0,Hibernate3.1
I,Construction......
II, To use Struts , Spring , Hibernate Required packages must be imported 1 , Struts ( No difference from before )2 , Spring Import
First, the framework of the download 1, struts2:http://struts.apache.org/download 2, Spring:http://www.springsource.org/download/community3, hibernate:http://sourceforge.net/projects/hibernate/files/hibernate4/. Create a project, add a JAR package 1, create a Java Web Project testssh.2, Add a struts package: Aopalliance-1.0.jar, freemarker-2.3.19.jar,ognl-3.0.5.jar,struts2-core-2.3.4.jar,struts2-spring-plug
Spring + Hibernate minor exception, SpringHibernate
Org. springframework. transaction. CannotCreateTransactionException: cocould not open Hibernate Session for transaction; nested exception is org. hibernate. exception. GenericJDBCException: Cannot open connectionAt org. springframework. orm. hibernate3.HibernateTransa
On spring transaction management Let's think about how we do data manipulation in hibernate when we don't use 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
A few days ago, I introduced a method for generating data tables using the tool class. However, the previous method requires a tool class that has little to do with the project. It is a bit redundant, so I will introduce a method to you today. That is, Hibernate and Spring work together to generate the table structure.
First, configure the web. xml configured for Sprin
The integration of the two frameworks after using Hibernate and the spring framework becomes quite easy,Why integrate hibernate?1. Managing Sessionfactory objects with the IOC feature of springLocalsessionfactorybean2. Manage session objects with springHibernatetemplate3. Implement declarative transaction management using Spring's featuresFirst step: Build
Persondao;
@Resource
sessionfactory;
Automatically injects the class to be invoked;
With such annotations, the corresponding Bean objects are not configured in the configuration file;
1, the introduction of the corresponding jar package, Spring package: Spring-aop spring-aspect spring-context
Spring integration hibernate consists of three parts: Hibernate configuration, Hibernate core objects to spring management, transactions by AOP control benefits:
Configuration by Java code, get rid of hard-coded, connect database and other information more flexible
If you consider using Spring or Hibernate with Ibm®websphere®application server, this article will explain how to configure these frameworks for various WebSphere application server scenarios. This article is not an exhaustive review of any framework, but rather an important reference to help you successfully implement such scenarios. (Updates are made for the Spring
The project is finished. However, the project performance is quite poor. As mentioned above, check whether the connection pool is not closed, so the pool will soon be filled up?
For this reason, I want to monitor information in the connection pool.
First
Thanks for the online example.
Proxool. xml
Bytes -----------------------------------------------------------------------------------------------------------------
User connection will not be acce
Spring and Hibernate integrate key points:1) Hibernate 's sessionfactory object is given to Spring to create;2) hibernate transaction is given to spring 's declarative transaction management.
1. Deptdao.java
Spring Integration Hibernate:Hibernate: Interacting with the databaseSPRING:IOC AOPIntegration points:1.sessionFactory objects are no longer generated by hibernate and are generated by spring, that is, the configuration of the database connection information global configuration map file is done by spring2.IOC managing DAO Objects Basedao objectsControl of 3.AOP
in development using struts+spring+hibernate, a blob or CLOB field is typically used in an Oracle database to store binary pictures or attachments. can easily solve the problem of read and write blobs by using the mapping method provided by the usertype of spring to handle lob types. references are as follows: ==============================================
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.