https://www.zhihu.com/question/21142149http://how2j.cn/k/hibernate/hibernate-tutorial/31.html?tid=63https://www.zhihu.com/question/29444491/answer/1464577571. Java-struts Framework TutorialStruts is an open source project sponsored by the Apache Software Foundation (ASF). By adopting JAVASERVLET/JSP technology, the application framework of MVC design pattern base
combinations use different queries: 1, lazy= "true" fetch = "select", using the delay policy, start querying only the main object, the association object will not query, only when the use of the time will be issued SQL statements to query; 2, lazy= "false" fetch = "select", do not use a delay policy, while querying out the main object and associated objects, resulting in 1+n SQL. 3, lazy= "true" or lazy= "false" fetch = "join", the delay will not work, because the use of an outer join query, wh
Workarounds when using Hibernate reverse engineering to select Java SRC folderEither the project already supports the Hibernate feature, and the. project file does not include a description of the attribute, or the project does not add hibernate attributes.I used the MyEclipse5.5.1 development tool, did not use the MyE
Java framework --- CRUD operations of hibernate, --- hibernatecrud
CRUD refers to the abbreviation of the first letter of the words "Create", "Retrieve", "Update", and "Delete" during computing.
The following examples are provided to illustrate these operations:
Entity class:
package com.oumyye.model;public class Student { private long id; private String name; private Class c; public long ge
Let's take a look at it.How to declare the transaction boundary through the jdbc api:
Connection provides the following methods to control transactions:
1. setautocommit (Boolean autocommit): sets whether to automatically submit transactions.
2. Commit (): commit a transaction
3. rollback (): cancels a transaction.
The following shows an example of an application:
Try {con = Java. SQL. drivermanager. getconnection (dburl, dbuser, d
Hibernate needs to know how to load (load) and store persisted classes of objects. This is what HibernateWhere the file plays a role. The mapping file tells Hibernate which table it should access in the database(table) and which fields within the table should be used (column).The basic structure of a mapping file looks like this:If you need to look at the DTD configuration file can go to the Hibernate3.jar
http://hibernate.org/42.html}. */public class Hibernatesessionfactory {/** * location of hibernate.cfg.xml file. * location should is on the classpath as Hibernate uses * #resourceAsStream style lookup for its configuration file. * The default classpath location of the hibernate config file was * in the default package. Use #setConfigFile () to update * The location of the configuration fi
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
Java Data types
Hibernate data type
Standard SQL data types(PS: May vary for different db)
BYTE, Java.lang.Byte
Byte
TINYINT
Short, Java.lang.Short
Short
SMALLINT
int, Java.lang.Integer
Integer
Ingeger
Long, Java.lang.Long
Long
BIGINT
float, java.lang.Float
Float
F
There are HQL query syntax in hibernate. But we are more familiar with the number of SQL statements, then how should we let hibernate support SQL? We don't have to think about it, the Hibernate team has already done it.Nonsense not to say, directly to the example.
It's a SQL statement, it's nonsense, it's an individual knows. We want
file (This file is an ant script that writes HBM2DDL and Hbm2java tasks, which allows for more flexible management of the project) XML version= "1.0" encoding= "UTF-8"?> 6. Process diagram for execution 7, the result of the execution diagram: Such as. Both Pojo and SQL have been successfully generated. --------------------------------------------------------------------------------------------------------------- --------------------------- In this special thanks to other predecessors of the sh
For example, for the Tuser class
1. Object Query
String hql = "from Tuser ";
Executing this statement will return records of Tuser and Tuser sub-classes.
Note: If the Tuser class has a foreign key, an error is returned during the query!
Solution: Select alias. Attribute from class as alias. No alias. Attribute still reports error!
Hql = "from Java. Lang. Object"
Records of all database tables in the database are returned.
Where statement
Hql = "from T
The Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but not to table and column operations, HQL to persistent objects and their properties. The HQL query is converted from hibernate to a traditional SQL query, which performs operations on the database on the lap.
Although you can use native SQL directly using SQL statements and hibe
HibernateThe father of Gavin King [1] suggested that developers upgrade to the Java EE 6 platform, and pointed out that some ideas that do not want to upgrade are not justified.
After the release of Java EE 6, I saw a lot of ideas against the upgrade to the new platform. Most of these objections are caused by Tomcat/Jetty and some open-source frameworks (such as Hiberna
mappings is almost identical to the preceding example, except with the different element and attribute names (
Bag mappingBag is a Java collection storage element that does not need to care about the order, but allows repeating elements in the list. Bag is a random grouping of objects in the list.
The collection collection is mapped to The RDBMS table and the Pojo class in the following example still use the above definition.To define a
Hibernate is an open source object-relational mapping framework that provides JDBC with a very lightweight object encapsulation that maps Pojo to database tables, is a fully automated ORM framework, and Hibernate automatically generates SQL statements, automatically executes, So that Java programmers can use object programming thinking to manipulate the database
In the development of Java server-side code, we will encounter the external parameters of the validity of validation, and Hibernate-validator provides some common parameter check annotations, we can use.The hibernate-validator corresponding jar is introduced in 1.maven:2. Define the field to validate in the model (that is, the field cannot be empty and the maximu
diagram: For example, both Pojo and SQL have been successfully generated. --------------------------------------------------------------------------------------------------------------- --------------------------- In this special thanks to other seniors for sharing, from his sharing and my groping, let me know how to use Hibernatetools in a Web project Two tools to generate what is needed. Of course, this is just into the door, Ascension also requires follow-up learning and practice ----------
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.