HibernateTemplate

org.springframework.orm.hibernate5.HibernateTemplate

这是spring-orm-4.3.4.RELEASE.jar包中的一个类,这个类是对Hibernate进行了封装;

这是可以进行注入的属性,需要注入sessionFactory属性,因此我们需要创建一个sessionFactory的Bean:

    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate"><property name="sessionFactory" ref=""></property></bean>

创建sessionFactory需要用到

org.springframework.orm.hibernate5.LocalSessionFactoryBean

这是spring-orm-4.3.4.RELEASE.jar包中的类

可注入的属性有:

 将sessionFactory注入到hibernateTemplate中:

 1     <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
 2         <property name="sessionFactory" ref="sessionFactory"></property>
 3     </bean>
 4     <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
 5         <property name="dataSource" ref="需要注入数据源"></property>
 6         <property name="hibernateProperties">
 7             <props>
 8                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
 9                 <prop key="hibernate.show_sql">true</prop>
10                 <prop key="hibernate.format_sql">true</prop>
11                 <prop key="hibernate.hbm2ddl.auto">update</prop>            
12                 <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>            
13             </props>
14         </property>
15         <property name="packagesToScan">
16             <array>
17                 <value>需要扫描的包</value>
18             </array>
19         </property>
20     </bean>
sessionFactory

 

创建sessionFactory还需要加载数据源和hibernate映射类的包;

    <bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="com.mysql.cj.jdbc.Driver"></property><property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssh?serverTimezone=GMT&amp;useSSL=false"></property><property name="user" value="root"></property><property name="password" value="zhangpn"></property>    

创建基类:

  1 package com.zhangpn.domain;
  2 
  3 import java.io.Serializable;
  4 
  5 import javax.persistence.Column;
  6 import javax.persistence.Entity;
  7 import javax.persistence.GeneratedValue;
  8 import javax.persistence.GenerationType;
  9 import javax.persistence.Id;
 10 import javax.persistence.Table;
 11 
 12 /**
 13  * 客户基类
 14  * 
 15  * @author Administrator
 16  *
 17  */
 18 
 19 @Entity
 20 @Table(name="cst_customer")
 21 public class Customer implements Serializable {
 22 
 23     @Id
 24     @Column(name="cust_id")
 25     @GeneratedValue(strategy=GenerationType.IDENTITY)
 26     private Long custId;
 27     
 28     @Column(name="cust_name")
 29     private String custName;
 30     
 31     @Column(name="cust_source")
 32     private String custSource;
 33     
 34     @Column(name="cust_industry")
 35     private String custIndustry;
 36     
 37     @Column(name="cust_level")
 38     private String custLevel;
 39     
 40     @Column(name="cust_address")
 41     private String custAddress;
 42     
 43     @Column(name="cust_phone")
 44     private String custPhone;
 45 
 46     public Long getCustId() {
 47         return custId;
 48     }
 49 
 50     public void setCustId(Long custId) {
 51         this.custId = custId;
 52     }
 53 
 54     public String getCustName() {
 55         return custName;
 56     }
 57 
 58     public void setCustName(String custName) {
 59         this.custName = custName;
 60     }
 61 
 62     public String getCustSource() {
 63         return custSource;
 64     }
 65 
 66     public void setCustSource(String custSource) {
 67         this.custSource = custSource;
 68     }
 69 
 70     public String getCustIndustry() {
 71         return custIndustry;
 72     }
 73 
 74     public void setCustIndustry(String custIndustry) {
 75         this.custIndustry = custIndustry;
 76     }
 77 
 78     public String getCustLevel() {
 79         return custLevel;
 80     }
 81 
 82     public void setCustLevel(String custLevel) {
 83         this.custLevel = custLevel;
 84     }
 85 
 86     public String getCustAddress() {
 87         return custAddress;
 88     }
 89 
 90     public void setCustAddress(String custAddress) {
 91         this.custAddress = custAddress;
 92     }
 93 
 94     public String getCustPhone() {
 95         return custPhone;
 96     }
 97 
 98     public void setCustPhone(String custPhone) {
 99         this.custPhone = custPhone;
100     }
101 
102     @Override
103     public String toString() {
104         return "Customer [custId=" + custId + ", custName=" + custName + ", custSource=" + custSource
105                 + ", custIndustry=" + custIndustry + ", custLevel=" + custLevel + ", custAddress=" + custAddress
106                 + ", custPhone=" + custPhone + "]";
107     }
108 
109 }
Customer基类

将packagesToScan属性进行注入,最终的applicationContext.xml内容是:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 5 
 6     <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
 7         <property name="sessionFactory" ref="sessionFactory"></property>
 8     </bean>
 9     <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
10         <property name="dataSource" ref="datasource"></property>
11         <property name="hibernateProperties">
12             <props>
13                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
14                 <prop key="hibernate.show_sql">true</prop>
15                 <prop key="hibernate.format_sql">true</prop>
16                 <prop key="hibernate.hbm2ddl.auto">update</prop>            
17                 <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>            
18             </props>
19         </property>
20         <property name="packagesToScan">
21             <array>
22                 <value>com.zhangpn.domain</value>
23             </array>
24         </property>
25     </bean>
26     <bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
27         <property name="driverClass" value="com.mysql.cj.jdbc.Driver"></property>
28         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssh?serverTimezone=GMT&amp;useSSL=false"></property>
29         <property name="user" value="root"></property>
30         <property name="password" value="zhangpn"></property>    
31     </bean>
32 </beans>
applicationContext.xml

再将事务管理配置:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:tx="http://www.springframework.org/schema/tx"
 5     xmlns:context="http://www.springframework.org/schema/context"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 7         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
 8         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
 9 
10     <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
11         <property name="sessionFactory" ref="sessionFactory"></property>
12     </bean>
13     <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
14         <property name="dataSource" ref="datasource"></property>
15         <property name="hibernateProperties">
16             <props>
17                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
18                 <prop key="hibernate.show_sql">true</prop>
19                 <prop key="hibernate.format_sql">true</prop>
20                 <prop key="hibernate.hbm2ddl.auto">update</prop>            
21                 <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>            
22             </props>
23         </property>
24         <property name="packagesToScan">
25             <array>
26                 <value>com.zhangpn.domain</value>
27             </array>
28         </property>
29     </bean>
30     <bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
31         <property name="driverClass" value="com.mysql.cj.jdbc.Driver"></property>
32         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssh?serverTimezone=GMT&amp;useSSL=false"></property>
33         <property name="user" value="root"></property>
34         <property name="password" value="zhangpn"></property>    
35     </bean>
36     <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
37         <property name="sessionFactory" ref="sessionFactory"></property>
38     </bean>
39     <tx:annotation-driven transaction-manager="transactionManager"/>    
40 </beans>
applicationContext.xml

(中间jdbcUrl有点小错误影响不大,修改过后以下是最终applicationContext.xml配置)

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:tx="http://www.springframework.org/schema/tx"
 5     xmlns:context="http://www.springframework.org/schema/context"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 7         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
 8         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
 9 <!-- Spring容器创建,扫描的包 -->
10     <context:component-scan base-package="com.zhangpn.*"></context:component-scan>
11 
12     <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
13         <property name="sessionFactory" ref="sessionFactory"></property>
14     </bean>
15     <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
16         <property name="dataSource" ref="datasource"></property>
17         <property name="hibernateProperties">
18             <props>
19                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
20                 <prop key="hibernate.show_sql">true</prop>
21                 <prop key="hibernate.format_sql">true</prop>
22                 <prop key="hibernate.hbm2ddl.auto">update</prop>            
23                 <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>            
24             </props>
25         </property>
26         <property name="packagesToScan">
27             <array>
28                 <value>com.zhangpn.domain</value>
29             </array>
30         </property>
31     </bean>
32     <bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
33         <property name="driverClass" value="com.mysql.cj.jdbc.Driver"></property>
34         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssh?serverTimezone=GMT"></property>
35         <property name="user" value="root"></property>
36         <property name="password" value="zhangpn"></property>    
37     </bean>
38     <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
39         <property name="sessionFactory" ref="sessionFactory"></property>
40     </bean>
41     <tx:annotation-driven transaction-manager="transactionManager"/>    
42 </beans>
applicationContext.xml

测试主方法:

 1 package com.zhangpn.Test;
 2 
 3 import java.util.Iterator;
 4 import java.util.List;
 5 
 6 import org.hibernate.criterion.DetachedCriteria;
 7 import org.springframework.context.ApplicationContext;
 8 import org.springframework.context.support.ClassPathXmlApplicationContext;
 9 import org.springframework.orm.hibernate5.HibernateTemplate;
10 
11 import com.zhangpn.domain.Customer;
12 
13 public class Test {
14 
15     public static void main(String[] args) {
16         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
17         HibernateTemplate hibernateTemplate = (HibernateTemplate) applicationContext.getBean("hibernateTemplate");
18         DetachedCriteria dCriteria = DetachedCriteria.forClass(Customer.class);
19         List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria);
20         for (Customer customer : customers) {
21             System.out.println(customer);
22         }
23     }
24 
25 }
测试类

主要代码:

    public static void main(String[] args) {ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");HibernateTemplate hibernateTemplate = (HibernateTemplate) applicationContext.getBean("hibernateTemplate");DetachedCriteria dCriteria = DetachedCriteria.forClass(Customer.class);List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria);for (Customer customer : customers) {System.out.println(customer);}}

最终,可以将数据库中的信息查询出来;

log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Mon Jun 11 12:01:45 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Mon Jun 11 12:01:45 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Mon Jun 11 12:01:45 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Hibernate: selectthis_.cust_id as cust_id1_0_0_,this_.cust_address as cust_add2_0_0_,this_.cust_industry as cust_ind3_0_0_,this_.cust_level as cust_lev4_0_0_,this_.cust_name as cust_nam5_0_0_,this_.cust_phone as cust_pho6_0_0_,this_.cust_source as cust_sou7_0_0_ fromcst_customer this_
Customer [custId=1, custName=张沛宁, custSource=1, custIndustry=长亮科技, custLevel=88级, custAddress=沛高中, custPhone=13613641361]
Customer [custId=2, custName=张沛龙, custSource=2, custIndustry=黑马科技, custLevel=45级, custAddress=沛高中, custPhone=13644441361]
Customer [custId=3, custName=刘晓云, custSource=3, custIndustry=瑞士科技, custLevel=55级, custAddress=徐一中, custPhone=13618582361]
Customer [custId=4, custName=zhangpn, custSource=5, custIndustry=American, custLevel=90, custAddress=江苏徐州, custPhone=13654874562]
Customer [custId=5, custName=小白, custSource=7, custIndustry=大学城, custLevel=20级, custAddress=常州大学, custPhone=13655479541]
Customer [custId=6, custName=zhangpn, custSource=5, custIndustry=American, custLevel=90, custAddress=刘德华, custPhone=13654874562]
Customer [custId=7, custName=44, custSource=666, custIndustry=22, custLevel=33, custAddress=11, custPhone=55]
Customer [custId=8, custName=搭建了, custSource=框架, custIndustry=你, custLevel=已经成功地, custAddress=恭喜, custPhone=SSH]

 findByCriteria方法:有两个用法;

第一种方法,不能分页;第二种方法,可以分页;

 findByCriteria意思是按照一定的标准去查找;那么这个标准是什么?我们怎么去定义这个标准?

答案是:Restrictions类


下面是 Restrictions的静态方法


 

举一个简单的例子:从表中查询custId为 5 的记录;

限制Restrictions定为:

Restrictions.eq("custId", 5L)

 

作为参数 :

    public static void main(String[] args) {ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");HibernateTemplate hibernateTemplate = (HibernateTemplate) applicationContext.getBean("hibernateTemplate");DetachedCriteria dCriteria = DetachedCriteria.forClass(Customer.class); dCriteria.add(Restrictions.eq("custId", 5L));List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria);for (Customer customer : customers) {System.out.println(customer);}}

 

 执行后结果:

Hibernate: selectthis_.cust_id as cust_id1_0_0_,this_.cust_address as cust_add2_0_0_,this_.cust_industry as cust_ind3_0_0_,this_.cust_level as cust_lev4_0_0_,this_.cust_name as cust_nam5_0_0_,this_.cust_phone as cust_pho6_0_0_,this_.cust_source as cust_sou7_0_0_ fromcst_customer this_ wherethis_.cust_id=?
Customer [custId=5, custName=小白, custSource=7, custIndustry=大学城, custLevel=20级, custAddress=常州大学, custPhone=13655479541]

 

 查询出来了!


 

如果查询多个条件,怎么办?

比如查询custSource=5并且custIndustry为“American”的记录:

 1     public static void main(String[] args) {
 2         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
 3         HibernateTemplate hibernateTemplate = (HibernateTemplate) applicationContext.getBean("hibernateTemplate");
 4         
 5         DetachedCriteria dCriteria = DetachedCriteria.forClass(Customer.class);
 6         
 7         dCriteria.add(Restrictions.eq("custSource", "5")).add(Restrictions.eq("custIndustry", "American"));
 8         
 9         List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria);
10         
11         for (Customer customer : customers) {
12             System.out.println(customer);
13         }
14     }

 

 运行结果:

Hibernate: selectthis_.cust_id as cust_id1_0_0_,this_.cust_address as cust_add2_0_0_,this_.cust_industry as cust_ind3_0_0_,this_.cust_level as cust_lev4_0_0_,this_.cust_name as cust_nam5_0_0_,this_.cust_phone as cust_pho6_0_0_,this_.cust_source as cust_sou7_0_0_ fromcst_customer this_ wherethis_.cust_source=? and this_.cust_industry=?
Customer [custId=4, custName=zhangpn, custSource=5, custIndustry=American, custLevel=90, custAddress=江苏徐州, custPhone=13654874562]
Customer [custId=6, custName=zhangpn, custSource=5, custIndustry=American, custLevel=90, custAddress=刘德华, custPhone=13654874562]

 

 


findByCriteria的另一种用法:

先看一下总记录:

Customer [custId=1, custName=张沛宁, custSource=1, custIndustry=长亮科技, custLevel=88级, custAddress=沛高中, custPhone=13613641361]
Customer [custId=2, custName=张沛龙, custSource=2, custIndustry=黑马科技, custLevel=45级, custAddress=沛高中, custPhone=13644441361]
Customer [custId=3, custName=刘晓云, custSource=3, custIndustry=瑞士科技, custLevel=55级, custAddress=徐一中, custPhone=13618582361]
Customer [custId=4, custName=zhangpn, custSource=5, custIndustry=American, custLevel=90, custAddress=江苏徐州, custPhone=13654874562]
Customer [custId=5, custName=小白, custSource=7, custIndustry=大学城, custLevel=20级, custAddress=常州大学, custPhone=13655479541]
Customer [custId=6, custName=zhangpn, custSource=5, custIndustry=American, custLevel=90, custAddress=刘德华, custPhone=13654874562]
Customer [custId=7, custName=44, custSource=666, custIndustry=22, custLevel=33, custAddress=11, custPhone=55]
Customer [custId=8, custName=搭建了, custSource=框架, custIndustry=你, custLevel=已经成功地, custAddress=恭喜, custPhone=SSH]

 

 第一个参数大家都肯定懂了吧,第二个和第三个分别是:开始位置 和 查询个数

List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria,0,3);

 

(dCriteria,0,3);意思就是按照约束标准从第0个开始查询,查询3条记录;执行后结果预计是前三条记录,我们来看一下:
测试源码:
 1 package com.zhangpn.Test;
 2 
 3 import java.util.List;
 4 
 5 import org.hibernate.criterion.DetachedCriteria;
 6 import org.springframework.context.ApplicationContext;
 7 import org.springframework.context.support.ClassPathXmlApplicationContext;
 8 import org.springframework.orm.hibernate5.HibernateTemplate;
 9 
10 import com.zhangpn.domain.Customer;
11 
12 public class Test {
13 
14     public static void main(String[] args) {
15         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
16         HibernateTemplate hibernateTemplate = (HibernateTemplate) applicationContext.getBean("hibernateTemplate");
17         
18         DetachedCriteria dCriteria = DetachedCriteria.forClass(Customer.class);
19         
20         //List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria);
21         List<Customer> customers = (List<Customer>) hibernateTemplate.findByCriteria(dCriteria,0,3);
22         
23         for (Customer customer : customers) {
24             System.out.println(customer);
25         }
26     }
27 
28 }
测试源码

 

 测试结果:

 1 log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
 2 log4j:WARN Please initialize the log4j system properly.
 3 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
 4 Mon Jun 11 12:42:28 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
 5 Mon Jun 11 12:42:28 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
 6 Mon Jun 11 12:42:28 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
 7 Hibernate: 
 8     select
 9         this_.cust_id as cust_id1_0_0_,
10         this_.cust_address as cust_add2_0_0_,
11         this_.cust_industry as cust_ind3_0_0_,
12         this_.cust_level as cust_lev4_0_0_,
13         this_.cust_name as cust_nam5_0_0_,
14         this_.cust_phone as cust_pho6_0_0_,
15         this_.cust_source as cust_sou7_0_0_ 
16     from
17         cst_customer this_ limit ?
18 Customer [custId=1, custName=张沛宁, custSource=1, custIndustry=长亮科技, custLevel=88级, custAddress=沛高中, custPhone=13613641361]
19 Customer [custId=2, custName=张沛龙, custSource=2, custIndustry=黑马科技, custLevel=45级, custAddress=沛高中, custPhone=13644441361]
20 Customer [custId=3, custName=刘晓云, custSource=3, custIndustry=瑞士科技, custLevel=55级, custAddress=徐一中, custPhone=13618582361]

 

 果然是3条记录,没毛病!


 

 更多的内容可以自己去尝试着测试,关键是环境要搭建好!

转载于:https://www.cnblogs.com/batj/p/9166303.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/353504.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

第四章: 4.1 logging模块 | 正则表达式

修改json数据然后写入json文件中 f open(1234.json,r,encodingutf-8) data f.read() data1 json.loads(data)data1[status] 1f1 open(1234.json,w,encodingutf-8)json.dump(data1,f1) hashlib md5值的用法 #加入下面这个就可以 password input(请输入密码:)m hashlib.md…

使用保险柜管理机密

您如何存储秘密&#xff1f; 密码&#xff0c;API密钥&#xff0c;安全令牌和机密数据属于秘密类别。 那是不应该存在的数据。 在容易猜测的位置&#xff0c;不得以纯文本格式提供。 实际上&#xff0c;不得在任何位置以明文形式存储它。 可以使用Spring Cloud Config Server或…

winScp中文乱码设置

打开一个putty窗口(图一)&#xff0c;左上角鼠标左键点击&#xff0c;弹出设置界面&#xff0c;选择Change Settings&#xff0c;在图二界面的window->translation&#xff0c;Remote character set选择UTF-8&#xff0c;Apply应用即可。 转载于:https://www.cnblogs.com/ya…

多台电脑共用一个耳机、音箱

台式机电脑声卡一般有三个插孔&#xff0c;一个是麦克风&#xff0c;一个是耳机&#xff0c;另一个就是LineIn输入口了&#xff0c;买一根AUX线&#xff0c;一头插入笔记本的耳机插口&#xff0c;另一头插入台式机linein口&#xff1b;在控制面板的声音中选择线路输入&#xff…

liferay开发文档_Liferay –简单主题开发

liferay开发文档实际上&#xff0c;Liferay的6.1版本已经走了很长一段路&#xff0c;该版本完全支持JSF和IceFaces。 我一直在努力学习它的绳索&#xff0c;因为我希望使其成为我们团队中的标准协作工具。 好的软件应用程序可以解决问题&#xff0c;但是好的软件应用程序不仅可…

ACRush 楼天城回忆录

利用假期空闲之时&#xff0c;将这几年 GCJ &#xff0c; ACM &#xff0c; TopCoder 参加的一些重要比赛作个回顾。首先是 GCJ2006 的回忆。 Google Code Jam 2006 一波三折&#xff1a; Google Code Jam 2006 是我第一次到美国参加现场的程序设计比赛。 Google Code Jam 2006…

JUnit 5 –条件

最近&#xff0c;我们了解了JUnit的新扩展模型以及它如何使我们能够将自定义行为注入测试引擎。 我向你保证要看情况。 现在就开始吧&#xff01; 条件允许我们在应该执行或不应该执行测试时定义灵活的标准。 它们的正式名称是“ 条件测试执行” 。 总览 本系列中有关JUnit 5…

我的编程竞赛之路 ——中国大学生计算机编程第一人楼天城访谈

记者/陈秋歌 25岁的楼天城有“中国大学生计算机编程第一人”的称号&#xff0c;也被参加竞赛的学子们敬称为“楼教主”。他的传奇经历一直激励着众多年轻学子&#xff1a;从2001年开始参加计算机编程竞赛&#xff0c;并连获全国一等奖&#xff1b;2004年入选国家集训队&#xf…

jenkins部署_Jenkins:部署JEE工件

jenkins部署随着持续集成和持续交付的出现 &#xff0c;我们的构建被分为不同的步骤&#xff0c;以创建部署管道。 这些步骤中的一些步骤可以是例如编译和运行快速测试&#xff0c;运行慢速测试&#xff0c;运行自动验收测试或发布应用程序等。 部署流程的最后步骤意味着将我们…

2013年3月编程语言排行榜:有毒的Java

2013年3月12日&#xff0c;Tiobe公布了新一期编程语言排行榜。Java依旧是占据第一的位置&#xff0c;C语言紧随其后。值得注意的Objective-C持续发力&#xff0c;已经占到了第三的位置。咋一看榜单&#xff0c;前5条中C#下滑最快&#xff0c;从第3名下降到第五名。而其他语言都…

DHCP服务(dhcpd)

DHCP动态分配主机地址&#xff08;Dynamic Host Configuration Protocol&#xff09; 动态主机配置协议&#xff08;DHCP&#xff09;是一种基于UDP协议且仅限于在局域网内部使用的网络协议&#xff0c;主要用于大型的局域网环境或者存在较多移动办公设备的局域网环境中&#x…

基于Matlab/Simulink不平衡电网工况下级联H桥光伏并网逆变器仿真模型

本次更新的内容为级联H桥光伏并网逆变器相关的控制&#xff0c;后面会针对储能系统在级联H桥拓扑上的应用进行分享。由于传统发电造成的环境污染问题和光伏电池板价格持续创新低&#xff0c;太阳能从众多种类的可再生能源中拔地而起&#xff0c;因而光伏逆变器成为国内外学者和…

“速课小龙”项目冲刺3

第三天 日期&#xff1a;2018/6/15 一.今日完成任务情况及遇到的问题 姓名完成情况遇到的问题解决方法邓旭 通过对昨天的知识进行再学习&#xff0c;已经能进行文件上传。并且开始着手于出题模块。 今天着手只是模型的基础层搭建&#xff0c;所以难度相对较少。未有问题解决陈逸…

Java和Lagom的CQRS

我很高兴在Chicago Java User Group上进行了讨论&#xff0c;并讨论了Lagom如何实现CQRS&#xff08;命令查询责任隔离模式&#xff09;。 值得庆幸的是&#xff0c;有一个录音&#xff0c;我还把这些幻灯片发布在slideshare上 。 抽象&#xff1a; 一旦应用程序变得相当复杂…

怎么样开会才有效果?

SAP项目实施过程中&#xff0c;难免不了要开不少的会议&#xff0c;无论是最前期的选型&#xff0c;还是商谈&#xff0c;乃至后面上线评审都免不了将很多项目干系人聚在一起就出现的问题或大家关心的问题摆在台面上做探讨。但只要你开过大会议你就会知道很多时候开会纯粹是为了…

网络15软工个人作业5——软件工程总结

一、请回望开学时的第一次作业&#xff0c;你对于软件工程课程的想象 1. 对比开篇博客你对课程目标和期待&#xff0c;“希望通过实践锻炼&#xff0c;增强计算机专业的能力和就业竞争力”&#xff0c;对比目前的所学所练所得&#xff0c;在哪些方面达到了你的期待和目标&#…

dijkstra算法学习

dijkstra算法学习 一、最短路径 单源最短路径&#xff1a;计算源点到其他各顶点的最短路径的长度 全局最短路径&#xff1a;图中任意两点的最短路径 Dijkstra、Bellman-Ford、SPFA求单源最短路径 Floyed可以求全局最短路径&#xff0c;但是效率比较低 SPFA算法是Bellman-Ford算…

php定时任务(自己)

php定时任务&#xff08;自己&#xff09; 一、总结 一句话总结&#xff1a;可用php.exe连接php文件和bat文件&#xff0c;bat文件在计划任务中可以设置定时执行&#xff0c; 二、 1、php 2、bat E: "D:\software\code\phpStudy2018\PHPTutorial\php\php-5.4.45\php.exe&q…

楼天城 楼教主

楼天城 求助编辑百科名片 楼天城楼天城是杭州人&#xff0c;姚期智教授的得意门生&#xff0c;正是姚教授发现他的才能后把他引上了现在的研究方向&#xff0c;并大力举荐他参加国际学术会议和比赛。在网络上他被称为“楼教主”&#xff0c;清华同学则简称他“教主”。中文名&a…

jpa 与非jpa 结合_EasyCriteria –使用JPA标准的简便方法

jpa 与非jpa 结合今天&#xff0c;我们将看到有关此工具的信息&#xff0c;该工具使使用JPA Criteria更加容易。 使用该库的应用程序将在JPA实现中更加简洁&#xff0c;易于使用和可移植。 在本文的结尾&#xff0c;您将找到要下载的源代码。 什么是标准&#xff1f; 当前是创…