Hibernate
BLUcoding
这个作者很懒,什么都没留下…
展开
-
Hibernate07_Hibernate Query Language
Hibernate07_Hibernate Query Language例1:String hql = "from People";Query query = session.createQuery(hql);List<People> list = query.list();for(People people : list) { System.out.println(people);}People(id=1, name=张三, money=1000.0)People(id=原创 2020-08-06 18:09:54 · 68288 阅读 · 0 评论 -
Hibernate06_配置文件详解
Hibernate06_配置文件详解dynamic-insert=“true” 动态添加测试:People people =new People();people.setName("李四");session.save(people);session.beginTransaction().commit();session.close();结果:Hibernate: insert into people (name, money)原创 2020-08-05 12:16:06 · 62450 阅读 · 0 评论 -
Hibernate05_延迟加载多对多
Hibernate05_延迟加载多对多注:Hibernate的多对多查询延迟加载默认是开启的lazy的取值为:true(默认),false, extra例:查询Course,加载对应的Account。测试:Configuration configuration = new Configuration().configure();SessionFactory sessionFactory = configuration.buildSessionFactory();Session session原创 2020-08-04 14:25:49 · 150797 阅读 · 0 评论 -
Hibernate04_延迟加载一对多
Hibernate04_延迟加载一对多以 Customer和Orders为例:Customerpackage com.blu.entity;import java.util.Set;import lombok.Data;@Datapublic class Customer { private Integer id; private String name; private Set<Orders> orders;}Orderspackage com.bl原创 2020-08-04 13:38:27 · 150849 阅读 · 0 评论 -
Hibernate03_多对多
Hibernate03_多对多多对多关系一门课程可以被多个学生选择,一个学生可以选择多门课程。学生和课程是多对多关系。在数据库中,学生和课程都是主表,中间表为从表。主表与中间表是一对多关系。数据表t_account表t_course表account_course中间表在实体类中:Accountpackage com.blu.entity;import java.util.Set;import lombok.Data;@Datapublic class Acco原创 2020-08-04 12:36:51 · 132000 阅读 · 0 评论 -
Hibernate02_一对多
Hibernate02_一对多一对多关系客户可以有多个订单,但每个订单只能属于一个客户。客户为一,订单为多。客户为主表,订单为从表。通过主外键关系来维护。数据表customer表orders表在实体类中:Peoplepackage com.blu.entity;import java.util.Set;import lombok.Data;@Datapublic class Customer { private Integer id; privat原创 2020-08-03 22:04:36 · 130887 阅读 · 1 评论 -
Hibernate01_使用原生接口开发
Hibernate01_使用原生接口开发新建 Maven ⼯程,pom.xml:<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 ht原创 2020-08-03 21:23:39 · 130747 阅读 · 0 评论