Learn about sample project using spring and hibernate, we have the largest and most updated sample project using spring and hibernate information on alibabacloud.com
Spring Learning (i): Using Intellijidea to create a MAVEN project for the Spring IOC test IOC concept
Control inversion (inversion of controls, abbreviated to IOC) is a design principle in object-oriented programming that can be used to reduce the degree of coupling between computer code. The most common way is called
, fraction) The annotated element must be a number whose value must be within an acceptable range @Past the annotated element must be a past date @Future the annotated element must be a future date @Pattern ( regex=,flag=) The annotated element must conform to the specified regular expression Hibernate Validator additional constraint @NotBlank (message =) The validation string is non-null and must be longer than 0 @Email the
This Sample Store Catalog App. Demonstrates the usage of JavaServer Faces, the new Java persistence APIs, and Spring 2.0 to Implement pagination. I took this example pagination of the Data Sets in a Sample application using JSF, Catalog façade stateless session, and Java Persistence APIs and modified it slightly to use
The project development tool uses the MYECLIPS3.6, first is establishes the project, the import struts+hibernate package, then configures the SRC and the directory hibernate.cfg.xml. I'm using the
MySQL database , So the configuration is as follows:
!--Properties-->
{ - //TODO auto-generated Method Stub + returnArg0.createquery ("from Claimvoucher C") - . Setfirstresult (first) + . Setmaxresults (pageSize) A . List (); at } - }); - } -}To add an instance of DAO in XML1 2 class= "Cn.bdqn.jboa.dao.UserDaoImpl" >3 4 5 Class= "Cn.bdqn.jboa.dao.ClaimVoucherDaoImpl" >6 7 Test class Public class Testclaim { @Test publicvoid Test () { new Classpathxmlapplicationc
so good that spring itself implements an MVC framework using dependency injection, called Spring MVC, and Spring integrates hibernate to handle things well. Make things management from the hibernate of the persistence layer to th
The environment in which the project is used:
Windows 10
JDK8
IntelliJ Idea 2017.1.3
Apache Tomcat 8
Maven 3.3.3
Create a new spring boot project using idea new projectSelect the spring Initializer type.Fill in the relevant
Contents of the Applicationcontext.xml configuration fileSummary of steps:1. Build a dependent jarSpring must jar (6)Hibernate must jarIntegration requires at least 3 jar,spring-jdbc.x.x to be imported, spring-tx.x.x,spring-orm.x.x2. The goal is to create a sessionfactoryManage Localsessionfactorybean to the
1. First implement an interface.
============================================================
Package Com.cqtele.tnbos;import java.util.*;p ublic interface Iuserdao {public void Insertuser (userInfo user); public Lis T Finduser (String SQL);
==============================================================
2. Implement this interface.
This simplifies the processing of Hibernate sessions using Spring's Aop
The IDE supports the Spring Project Creation Wizard to quickly create a spring boot project;Select the modules we need; The wizard will create the spring boot project online;The default generated
"; to + } - the}1234 - - + - + A at - - - - - in - to + - the * $Panax Notoginseng - the + A theYou can override the error prompt defined on a persisted object by defining a "validatemessage.properties" file, usually in the form of a property key in the properties file "@Annotation Name.object.fieldname":NotEmpty.customer.name = name is required! Range.customer.age = age value must is between 1 and 150Code Run Demo:Springmvc-bean-validation-jsr303-example-2.zip5. Referencehttp://ww
spring-framework-3.2.4 and hibernate-release-4.3.5 use Hibernatedaosupport to throw an exception java.lang.ClassCastException: Org.springframework.orm.hibernate4.SessionHolder cannot is cast to Org.springframework.orm.hibernate3.SessionHolder. Solution:After the LZ opens the Spring jar package, it discoversThere are no hibernatedaosupport classes in Org.springfra
Tomcat.Previous projects, also useless such a problem.Never be too foolish.Look at the configuration of the jetty:plugin> groupId>Org.mortbay.jettygroupId> Artifactid>Maven-jetty-pluginArtifactid> version>6.1.5version> Configuration> Hot Deploy - Scanintervalseconds>1Scanintervalseconds> webappsourcedirectory>Src/main/webappwebappsourcedirectory> Scanintervalse
("gethtmlcomponent");// Gethtmlcomponent is a bean defined in spring that implements some initialization of the logic and operation of the database, in which the hibernate operation database can be calledGethtmlcomponent.getcomponentvalue (Event.getservletcontext ());
SYSTEM.OUT.PRINTLN ("Startuplistener initialization ends. ");}
}
Configure the following in Web. xml
Com. GWJ.listener.StartupListener
Th
There are two ways to configure Hibernate mappings in spring to implement the
1: When the required mapping file is less, can be implemented by mappingresources
The specific implementation is as follows:
The main thing is to use
The advantages of this realization: more intuitive, easy to understand, the drawback is: if the mapping file too much, one is too much repetition of code, the second is if the
naturally forms the guidance of how code is distributed. More importantly, the framework eases the pain of developers writing code like the persistence layer from scratch, and makes them focus on the application logic that is important to the customer.
This article will discuss how to combine several well-known frameworks for loose-coupling purposes, how to build your architecture, and how to keep your application tiers consistent. The challenge is to combine these frameworks so that each laye
Discover a simplified way for spring Hibernate annotations
Original Way
Simplified Way
When an entity is stored under multiple paths, it is listed as a list:
Using MAVEN to create a Java Web project (Spring MVC) uses the following tools:1. Maven 3.22, IntelliJ idea 133. JDK 1.74. Spring 4.1.1 Released5, TOMCAT76. Logback 1.0.13 Log Output componentThe next step is to show how to create a Web project with a maven template1. Use Ma
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.