toString method to output information.
}
}
Then
Add bean-related configuration in the configuration file AppliccationContext. xml (this is a value injection, interface and construction injection)
Test code
Public class testPerson {Public static void main (String [] args ){XmlBeanFactory beansfactory = new XmlBeanFactory (new FileSystemResource ("src/ApplicationContext. xml "));System. out. println (beansfactory );Person nike = (Person) beansfactory. getBean ("nike ");System. out. println (
Spring provides great support for Hibernate integration. Spring provides initialization for sessionfactory, So you no longer need to worry about session open and close. Spring also provides flexible transaction declarations.
This article describes how to integrate Hibernate
Document directory
How does hibernate work and why?
How does hibernate delay loading?
In hibernate, how does one implement the relationship between classes? (For example, one-to-many and many-to-many relationships)
Let's talk about the cache mechanism of hibernate.
Hibernate
Over the past few days, I have made Hibernate and spring look good. I think about some of struts's things and decided to integrate the three things. The presentation layer uses STRUTS + freemarker and the business layer uses spring, hibernate processes the persistent layer. In struts, authorization is used to delegate
Spring + springmvc + hibernate integrated instance, springmvchib.pdf
In the previous blog, I wrote about the integration of spring and springmvc, and added hibernate to this article.
Like the previous one, this time is still a pilot jar package. This time, you need to add the jar package in
The key to spring and hibernate integration is that Hibernate's sessionfactory is created by the spring IOC container, and Hibernate's transactions are managed by spring's AOP. Note: Because of the integration, the configuration in Hibernate configuration file (Hibernate.cfg.xml) can be written to the
It's actually very simple.
The first method is to use hiberante. cfg. xml:
The configuration of hiberante. cfg. XML is as follows:
"-// Hibernate/hibernate configuration DTD 3.0 // en"Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">Org. hibernate. dialect. mysqldialectThen configure applicationContext
SPRINGMVC:The Spring framework is highly configurable and includes a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, IText, and POI. The Spring MVC framework does not know which view to use, so you can choose the view autonomously. Spring MVC separates the roles of controllers, model objects, dispatchers, and handler obje
struts+hibernate+spring Implement User Login functionThrough the login case to achieve the integration between the three frameworks, the login function is a necessary module for any system and software, but through this module to understand these complex framework technology, understanding the data flow and the whole design idea is quite easy. Only after mastering the application of these small modules, it
Struts, Hibernate, and spring are common keys in our Java development, and they provide the most appropriate solution for different scenarios. But do you know how these well-known frameworks were originally created?We know that traditional Java Web applications are implemented using Jsp+servlet+javabean, which implements the most basic MVC layering, which divides the program structure into several layers, t
Struts: used for VC, that is, control and display;
Spring: used for transaction processing of database operations. It is OK after being configured in the configuration file;
Hibernate: used for Dao processing. Here, the gethibernatetemplate () method of spring is used to operate hsql for data addition, deletion, modification, and other operations.
1. Let's talk
long ago, I heard of SSH, at first thought is a thing, the specific content is unknown, always feel high-end atmosphere on the grade, after learning to find, not only on the tall, but also low-key luxury has connotation, after a period of research and study of the basic principles of SSH framework and ideas, finally grounded gas. As a beginner, a little bit of harvest, want to through the form of Bowen and everyone to share, common progress, in the process of updating the blog will inevitably ha
This article belongs to reprint, from Baidu question Http://zhidao.baidu.com/question/213823575.html?qbl=relate_question_0word=beans%20publicSsh:Struts (presentation layer) +spring (business layer) +hibernate (persistence layer)Struts:Struts is a presentation-layer framework that mainly functions as interface display, receiving requests, and distributing requests.In the MVC framework, struts belongs to the
Struts: Responsible for the display layer, is a perfect MVC implementation, it calls the business layer to complete the operational logic, the business layer calls the persistence layer to complete the database read and write.Hibernate: Creates a series of persisted classes that correspond to the properties of each class to the database table's property one by one.Spring: relies on injection and control inversion. As soon as you get a class that implements this interface, you can easily inject t
Learn extjs5 with me (27 -- adding the Server web, spring, and hibernate configuration files ),Learn extjs5 with me (27 -- adding the Server web, spring, and hibernate configuration files)
We created a java web project before. Now we need to add the jar packages connected by spr
menu. On libraries selection, spring 3.0 AOP Libraries, Spring 3.0 Core Libraries, Spring 3.0 Persistence Core Libraries, Spring 3.0 Persistence JDBC Libraries, and Spring 3.0 Web Libraries need to be added;
4. add support for Hibernate
SpringMVC + Spring + Hibernate, springmvchib.pdf
Although Strusts2 + Spring + Hibernate is the mainstream WEB development framework, SpringMVC is widely used by more and more people!
Here is a small example of SpringMVC + Spring + Hibern
Struts: used for VC, that is, control and display;Spring: used for transaction processing of database operations. It is OK after being configured in the configuration file;Hibernate: used for Dao processing. Here, the gethibernatetemplate () method of spring is used to operate hsql for data addition, deletion, modification, and other operations. 1. Let's talk a
));
Auditmanager. log () occurs in the new TX context, if auditmanager. log () itself is successful (that is, there is no exception), it will be submitted.
Create a sample Environment
In order to establish the sample environment, I followed the steps of the reference spring live:
1. download and install the following components. During the operation, pay attention to the accurate version number. Otherwise, the version mismatch may occur.
·
entity.hbm.xmlConfiguration information4, the creation of DAO layer, Service layer (basic additions and deletions for testing)PS. Description: The DAO implementation class inherits the Hibernatedaosupport and can get the session directly without the need of sessionfactory.5, the action layer in front of the configuration struts2 on the basis of the addition of business code (increase and deletion of check)There are two ways to get a userservice:Get/set WayAnnotation method6, in the Applicationc
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.