tags: Hibernate JDBC Oracle MySQL SQL Server
beginTransaction();
close();
Connection () : **** This method directly obtains the JDBC connection, bypassing Hibernate to directly access the database, the addition, deletion, and generally will be more efficient than Hibernate.
delecte();
Get( Class entityClass,Serializable id); If there is no corresponding instance, it will return null
Load( Class entityClass,Serializable id);//If there is no corresponding instance, it will throw an exception.
save(Object entity);
update(Object entity)
saveOrUpdate(Object entity)
isInitialized() and initialize() ;/// can solve the problem of lazy loading better.
//1
Criteria criteria = session.createCriteria(User.class);
List list = criteria.list();
//2 pagination
criteria.add(Restriction.eq("id",new Integer(1)));
criteria.setMaxResults(10);
User user = (User) criteria.uniqueResult()//Load a single object
criteria.addOrder(Order.desc("id");)
//3 joint query
Criteria cusCriteria = session.createCriteria(Customer.class);//
Criteria ordCriteria = cusCriteria.createCriteria("orders");//
ordCriteria.add(Restrictions.gt("money",new Double(1000)));
...
//4 offline query (bind to the session only when the query is executed) (usually used to dynamically build query statements)
/ / In the presentation layer constructs the query statement
DetachedCriteria dCritera = DetachedCriteria.forClass(Order.class);
dCritera.add(Restrictions.gt("money",new Double(1000)));
....
serviec.queryOrders(dCritertia);
Session session = ....
//In the business layer
Critertia criteria = dCritertia.getExecutable(session);
criteria.list();
for(int i=0;i<1000;i++){
....
session.save(customer);
if(i%50 ==0 ){
Session.flush () ;/ / synchronize this batch of data with the database
Session.clear () ;/ / clear the buffer area, release memory to attack a batch of use
}
}
<property name="hibernate.query.facotry_class">
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</property>
The front-end css style uses the vue framework, and its own css style is duplicated with the custom name, causing the style to be overwritten. original custom style, Custom style after modification, W...
The notes are from the hibernate course of the horse soldier teacher. 1, class to table @table specifies the table name @column specifies the field name @Transient specifies fields that do not need to...
Article Directory Overview of reflection mechanisms The role of reflection: Specific and popular understanding of reflection dynamics: Main APIs related to reflection Specific use of reflection: Dynam...
sheet_name The name, string/number of the sheet you want to open; the following operations are equivalent headerWhich row is the column label row index_col Which column is used as the row label (index...
...
1. Overview of the frame 1.1. What is the framework Frame: refers to the semi-finished software to complete some of the features. 2.EE three-tier architecture 2.1 EE classic three-tier structure: 3 .H...
Beginner hibernate, configure appear after running 1、hibernate.dialect 'must be set when no Connection available error; Check the configuration file, write it right just do not know what went wrong, d...
A, web review JavaEE three-tier structure: 1, web layer: Struts2 2, service layer: spring 3, dao layer: Hibernate (complete change search database additions and deletions) Second, the idea of unders...
1.hibernate of five core interfaces Interface configuration Configure hibernate hibernate open instance of the object created sessionFactory SessionFactory interfaces Initializing a hibernate sessionF...
Annotation example One-to-many Many-to-one ---------------Employee.java----------------- package com.huarui.entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persi...