- 博客(5)
- 收藏
- 关注
原创 基于Hibernate实现CRUD
基于Hibernate实现CRUD 1、增加 public void testSave(){ Customer c=new Customer(); c.setName("a"); Configuration cfg=new Configuration().configure(); SessionFactory factory=cfg.buildSessionFactory(); Session session=factory.openSession(); Transaction tx=
2021-06-16 19:15:26 66
原创 第四次 分页查询
分页查询 分页查询,就是将将过多的结果在有限的界面上分好多页来显示 public void testQueryUsersByPage() { SessionFactory sf = null; Session session = null; Transaction ts = null; try { sf = HibernateUtil.getSessionFactory();// SessionFactory单态模式 session = sf.getCurrentSession
2021-06-16 18:44:18 64
原创 简单查询 单例模式
Session Session 是持久层操作的基础,相当于JDBC中的Connnection。 Configuration config=new Configuration().configure(); //读取默认的hibernate.cfg.xml的文件 SessionFactory sessionFactory=config.buildSessionFactory(); //通过config创建sessionFactory的实例 Session ses
2021-06-16 17:55:57 85
原创 equals以及 hashCode方法 重写
** 重写 equals 以及 hashCode 方法 ** hashCode & equals: 在Object类中,hashCode()返回的是根据对象的存储地址计算出来一个哈希值,equals()是判断两个对象的内存地址是否相等。**所以hashCode主要是用于查找使用的,而equals()是用于比较两个对象是否相等的。**但当需要重写这两个方法时,需要注意三点: 如果两个对象的equals()结果为true,那么这两个对象的hashCode一定相同 两个对象的hashCode()结果相
2021-06-16 17:22:15 320
原创 使用ecplise进行hibernate环境配置
使用ecplise进行hibernate环境配置 跟着老师视频操作 第一步准备相关材料 添加jar包 继续导入xml文件 <!-- ~ Hibernate, Relational Persistence for Idiomatic Java ~ ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. ~ See the lgpl.txt file in the root directory
2021-05-10 22:44:56 120 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人