Hibernate入门(一)

hibernate介绍

操作数据库的时候,可以以面向对象的方式来完成.不需要书写SQL语句

引入约束

hibernate-core-5.0.7.Final.jar

org.hibernate-hibernate-configuration-3.0.dtd

http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd

新建xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

 hibernate框架的搭建

配置文件详解

扫描二维码关注公众号,回复: 40791 查看本文章

hibernateAPI详解

Configuration

SessionFactory

Session

获得全新session  Session session = sf.openSession();

获得与线程绑定的session  sf.getCurrentSession();

Transaction

BeanUtils.populate的用法

BeanUtils位于org.apache.commons.beanutils.BeanUtils下面,其方法populate的作用解释如下:

完整方法:

BeanUtils.populate( Object bean, Map properties ),

这个方法会遍历map<key, value>中的key,如果bean中有这个属性,就把这个key对应的value值赋给bean的属性。

Customer c = new Customer();

BeanUtils.populate(c, request.getParameterMap());

猜你喜欢

转载自www.cnblogs.com/cnki/p/8906381.html