Hibernate--对象关系
在hibernate中,关联关系映射分为单向关联和双向关联。共有七种关系
·@Many To One
·@One To Many(单向)
·@One To Many(多向)
·@One To One(单向)
·@One To One(多向)
·@Many To Many(单向)
·@Many To Many(多向)
hibernate在维护这几种关系的时候,要不通过连接表,要不通过外键的方式。
这是一种最常见的关系,hibernate是通过在many的一方加入one的一个主键作为外键的方式来管理关系的。
此时的多的一方和一的一方,需要各自管理,分别保存,也可以在many-to-one的配置中加入级联属性,则在保存多的一端的时候,会自动保存一的一端
先看配置文件版
package com.fuwh.model; //one public class Father {private int id;private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.model; //Many public class Child {private int id;private String name;//在many的一端中加入one作为一个属性变量private Father father;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Father getFather() {return father;}public void setFather(Father father) {this.father = father;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Father" table="t_father"><id name="id" column="fatherId"><generator class="native"></generator></id><property name="name" column="fatherName"></property></class></hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Child" table="t_child"><id name="id" column="childId"><generator class="native"></generator></id><property name="name" column="childName"></property><!-- 单向多(child)对一(father)的关系会在多(child)的一方生成的表中添加一个外键,指向一(father)的主键需要在多(child)的一方配置many-to-onename:指定类中的Father对象变量column:指定外键名字
cascade:表示级联操作,包含以下集中取值none(默认),all,persist, merge, delete, save-update, evict, replicate,lock and refresh,delete-orphan ;可以用逗号隔开,表示几个取值,all代表所有的-->
<many-to-one name="father" column="father_Id" cascade="all"></many-to-one></class></hibernate-mapping>
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration><session-factory><!-- 数据库连接设置 --><property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property><property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate</property><property name="hibernate.connection.username">root</property><property name="hibernate.connection.password">mysqladmin</property><!--指定方言,表明用的是哪种数据库,也可以不指定,hibernate默认会翻译成正确的数据库脚本方言可以在 hibernate-release-xx.xx/project/etc/hibernate.properties 中查找--><property name="hibernate.dialect">MySQL5</property><!-- 设定时候更新表结构,不存在或自动创建 --><property name="hibernate.hbm2ddl.auto">update</property><!-- 配置 在后台打印出sql语句 --><property name="hibernate.show_sql">true</property><property name="hibernate.format_sql">true</property><!-- 引入实体类和表的映射文件 --><mapping resource="/com/fuwh/model/Father.hbm.xml"/><mapping resource="/com/fuwh/model/Child.hbm.xml"/></session-factory></hibernate-configuration>
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();session.getTransaction().commit();session.close();}}
执行空的测试语句,生成的sql文如下
Hibernate: create table t_child (childId integer not null auto_increment,childName varchar(255),father_Id integer,primary key (childId)) Hibernate: create table t_father (fatherId integer not null auto_increment,fatherName varchar(255),primary key (fatherId)) Hibernate: alter table t_child add constraint FKg4qwua9ltkkkfik7fsvubyou7 foreign key (father_Id) references t_father (fatherId)
操作表中的数据
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.model.Child; import com.fuwh.model.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father=new Father();father.setName("爸爸");//因为在多的一断配置了级联属性为all,就表明把操作都交给了多的一端来维护关系,不需要保存father对象//在保存child的时候,会自动保存father Child child1=new Child();child1.setName("儿子1");child1.setFather(father);Child child2=new Child();child2.setName("儿子2");child2.setFather(father);session.save(child1);session.save(child2);
session.getTransaction().commit();session.close();}
}
生成的sql文
Hibernate: insert intot_father(fatherName) values(?) Hibernate: insert intot_child(childName, father_Id) values(?, ?) Hibernate: insert intot_child(childName, father_Id) values(?, ?)
注解版
package com.fuwh.mto;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;import org.hibernate.annotations.GenericGenerator;@Entity public class Father {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="fatherName")private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.mto;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne;import org.hibernate.annotations.GenericGenerator;@Entity public class Child {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="childName")private String name;/*** 定义多对一* JoinCloumn中的name指定外键的列名,foreignkey中指定定义的外键的名字* 这一列也可以不加,不加就是默认的设置*/@ManyToOne(cascade=CascadeType.ALL)@JoinColumn(name="father_id",foreignKey=@ForeignKey(name="FATHER_ID_FK"))private Father father;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Father getFather() {return father;}public void setFather(Father father) {this.father = father;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.mto.Child; import com.fuwh.mto.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father=new Father();father.setName("爸爸");Child child1=new Child();child1.setName("儿子一");child1.setFather(father);Child child2=new Child();child2.setName("儿子二");child2.setFather(father);session.save(child1);session.save(child2);session.getTransaction().commit();session.close();} }
@One To Many关系把一个父节点和多个子节点联系起来,如果在子节点没有一个@Many To One和@One To Many相匹配的话,那就是一个单向的@One To Many,否则的话就是一个多向的@One To Many,并且可以在任意一边来维护关系。
package com.fuwh.model;import java.util.ArrayList; import java.util.List;public class Father {private int id;private String name;private List<Child> children=new ArrayList<Child>();public List<Child> getChildren() {return children;}public void setChildren(List<Child> children) {this.children = children;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.model;public class Child {private int id;private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Child" table="t_child"><id name="id" column="childId"><generator class="native"></generator></id><property name="name" column="childName"></property></class></hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Father" table="t_father"><id name="id" column="fatherId"><generator class="native"></generator></id><property name="name" column="fatherName"></property><set name="children" cascade="true"><key column="father_Id"></key><one-to-many class="com.fuwh.model.Child"/></set></class></hibernate-mapping>
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();session.getTransaction().commit();session.close();} }
生成的sql文
Hibernate: create table t_child (childId integer not null auto_increment,childName varchar(255),
father_Id integer,
primary key (childId)) Hibernate: create table t_father (fatherId integer not null auto_increment,fatherName varchar(255),primary key (fatherId)) Hibernate: alter table t_child add constraint FKev9uk6ojrjsv10ba9qoa4yhsy foreign key (father_Id) references t_father (fatherId)
注解版
package com.fuwh.otm;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;import org.hibernate.annotations.GenericGenerator;@Entity public class Child {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="childName")private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.otm;import java.util.ArrayList; import java.util.List;import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany;import org.hibernate.annotations.GenericGenerator;@Entity public class Father {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="fatherName")private String name;//orphanRemoval:表示在删除集合中的child的时候,也会删除child表中的相应纪录@OneToMany(cascade=CascadeType.ALL,orphanRemoval=true)private List<Child> children=new ArrayList<Child>(); public List<Child> getChildren() {return children;}public void setChildren(List<Child> children) {this.children = children;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.otm.Child; import com.fuwh.otm.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father1=new Father();father1.setName("爸爸1");Father father2=new Father();father2.setName("爸爸2");Child child1=new Child();child1.setName("儿子一");Child child2=new Child();child2.setName("儿子二");father1.getChildren().add(child1);father1.getChildren().add(child2);session.save(father1);session.getTransaction().commit();session.close();} }
package com.fuwh.model;public class Child {private int id;private String name;private Father father;public Father getFather() {return father;}public void setFather(Father father) {this.father = father;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.model;import java.util.HashSet; import java.util.Set;public class Father {private int id;private String name;private Set<Child> children=new HashSet<Child>();public Set<Child> getChildren() {return children;}public void setChildren(Set<Child> children) {this.children = children;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Father" table="t_father"><id name="id" column="fatherId"><generator class="native"></generator></id><property name="name" column="fatherName"></property><set name="children"><key column="father_Id"/><one-to-many class="com.fuwh.model.Child"/></set></class></hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Child" table="t_child"><id name="id" column="childId"><generator class="native"></generator></id><property name="name" column="childName"></property><many-to-one name="father" column="father_Id" cascade="all"></many-to-one></class></hibernate-mapping>
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.model.Child; import com.fuwh.model.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father=new Father();father.setName("爸爸");Child child1=new Child();child1.setName("儿子1");Child child2=new Child();child2.setName("儿子2");child1.setFather(father);child2.setFather(father);father.getChildren().add(child1);father.getChildren().add(child2);session.save(child1);session.save(child2);session.getTransaction().commit();session.close();} }
生成的sql
Hibernate: selectfather0_.fatherId as fatherId1_1_0_,father0_.fatherName as fatherNa2_1_0_ fromt_father father0_ wherefather0_.fatherId=? Hibernate: selectchild0_.childId as childId1_0_0_,child0_.childName as childNam2_0_0_,child0_.father_Id as father_I3_0_0_ fromt_child child0_ wherechild0_.childId=? Hibernate: selectchildren0_.father_Id as father_I3_0_0_,children0_.childId as childId1_0_0_,children0_.childId as childId1_0_1_,children0_.childName as childNam2_0_1_,children0_.father_Id as father_I3_0_1_ fromt_child children0_ wherechildren0_.father_Id=? Hibernate: updatet_child setchildName=?,father_Id=? wherechildId=? Hibernate: updatet_child setfather_Id=? wherechildId=?
注解版
package com.fuwh.otmbi;import java.util.ArrayList; import java.util.List;import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany;import org.hibernate.annotations.GenericGenerator;@Entity public class Father {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="fatherName")private String name;/*** orphanRemoval:表示在删除集合中的child的时候,也会删除child表中的相应纪录* mappedBy/inverse:表示由另一方来维护关系* */@OneToMany(mappedBy="father",cascade=CascadeType.ALL,orphanRemoval=true)private List<Child> children=new ArrayList<Child>(); public List<Child> getChildren() {return children;}public void setChildren(List<Child> children) {this.children = children;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.otmbi;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne;import org.hibernate.annotations.GenericGenerator;@Entity public class Child {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="childName")private String name;@ManyToOneprivate Father father;public Father getFather() {return father;}public void setFather(Father father) {this.father = father;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.otmbi.Child; import com.fuwh.otmbi.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father1=new Father();father1.setName("爸爸1");Child child1=new Child();child1.setName("儿子一");child1.setFather(father1);Child child2=new Child();child2.setName("儿子二");child2.setFather(father1);father1.getChildren().add(child1);father1.getChildren().add(child2);session.save(father1);session.getTransaction().commit();session.close();} }
单向的关系又可以分为基于主键的关联和基于外键的关联。
基于外键
package com.fuwh.model;public class Wife {private int id;private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.model;public class Husband {private int id;private String name;private Wife wife;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Wife getWife() {return wife;}public void setWife(Wife wife) {this.wife = wife;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Wife" table="t_wife"><id name="id" column="wifeId"><generator class="native"></generator></id><property name="name" column="wifeName"></property></class></hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Husband" table="t_husband"><id name="id" column="husbandId"><!-- 主键生成策略为 外键 指向 wife--><generator class="foreign"><param name="property">wife</param></generator></id><property name="name" column="husbandName"></property><one-to-one name="wife" constrained="true"/></class></hibernate-mapping>
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.model.Child; import com.fuwh.model.Father; import com.fuwh.model.Husband; import com.fuwh.model.Wife;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Husband husband=new Husband();Wife wife=new Wife();wife.setName("老婆");husband.setName("老公");husband.setWife(wife);session.save(wife);session.save(husband);session.getTransaction().commit();session.close();} }
生成的sql文
Hibernate: create table t_husband (husbandId integer not null,husbandName varchar(255),primary key (husbandId)) Hibernate: create table t_wife (wifeId integer not null auto_increment,wifeName varchar(255),primary key (wifeId)) Hibernate: alter table t_husband add constraint FK2tae450lphjy8nciwyrxxlfkv foreign key (husbandId) references t_wife (wifeId) Hibernate: insert intot_wife(wifeName) values(?) Hibernate: insert intot_husband(husbandName, husbandId) values(?, ?)
在单向一对一中,hibernate默认是让client-side(上例的Husband)通过外键来管理关系的。
注解版
package com.fuwh.oto;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;import org.hibernate.annotations.GenericGenerator;@Entity public class Father {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="fatherName")private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.oto;import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne;import org.hibernate.annotations.GenericGenerator;@Entity public class Child {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="childName")private String name;@OneToOne(cascade=CascadeType.ALL)@JoinColumn(name="father_id")private Father father;public Father getFather() {return father;}public void setFather(Father father) {this.father = father;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.oto.Child; import com.fuwh.oto.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father1=new Father();father1.setName("爸爸1");Child child1=new Child();child1.setName("儿子一");child1.setFather(father1);session.save(child1);session.getTransaction().commit();session.close();} }
package com.fuwh.model;public class Wife {private int id;private String name;private Husband husband;public Husband getHusband() {return husband;}public void setHusband(Husband husband) {this.husband = husband;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Wife" table="t_wife"><id name="id" column="wifeId"><generator class="native"></generator></id><property name="name" column="wifeName"></property><one-to-one name="husband"/></class></hibernate-mapping>
Hibernate: create table t_husband (husbandId integer not null,husbandName varchar(255),primary key (husbandId)) Hibernate: create table t_wife (wifeId integer not null auto_increment,wifeName varchar(255),primary key (wifeId)) Hibernate: alter table t_husband add constraint FK2tae450lphjy8nciwyrxxlfkv foreign key (husbandId) references t_wife (wifeId) Hibernate: insert intot_wife(wifeName) values(?) Hibernate: insert intot_husband(husbandName, husbandId) values(?, ?)
注解版
package com.fuwh.otobi;import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToOne;import org.hibernate.annotations.GenericGenerator;@Entity public class Father {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="fatherName")private String name;@OneToOne(mappedBy="father",cascade=CascadeType.ALL,fetch=FetchType.LAZY)private Child child;public Child getChild() {return child;}public void setChild(Child child) {this.child = child;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.otobi;import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne;import org.hibernate.annotations.GenericGenerator;@Entity public class Child {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="childName")private String name;@OneToOne(cascade=CascadeType.ALL)@JoinColumn(name="father_id")private Father father;public Father getFather() {return father;}public void setFather(Father father) {this.father = father;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.otobi.Child; import com.fuwh.otobi.Father;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Father father1=new Father();father1.setName("爸爸1");Child child1=new Child();child1.setName("儿子一");child1.setFather(father1);session.save(child1);session.getTransaction().commit();session.close();} }
@Many-To-Many关系需要一个连接表来连接两张表。
package com.fuwh.model;public class Wife {private int id;private String name;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.fuwh.model;import java.util.HashSet; import java.util.Set;public class Husband {private int id;private String name;private Set<Wife> wives=new HashSet<Wife>();public Set<Wife> getWives() {return wives;}public void setWives(Set<Wife> wives) {this.wives = wives;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Wife" table="t_wife"><id name="id" column="wifeId"><generator class="native"></generator></id><property name="name" column="wifeName"></property></class></hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Husband" table="t_husband"><id name="id" column="husbandId"><generator class="native"/></id><property name="name" column="husbandName"></property><set name="wives" cascade="all"><!-- key 指定连接表的主键列 many-to-many:中的列指定连接另一端的列,或对应的类--><key column="husband_id"></key><many-to-many column="wife_id" class="com.fuwh.model.Wife"></many-to-many></set></class></hibernate-mapping>
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.model.Child; import com.fuwh.model.Father; import com.fuwh.model.Husband; import com.fuwh.model.Wife;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Husband husband=new Husband();husband.setName("老公");Wife wife1=new Wife();wife1.setName("老婆1");Wife wife2=new Wife();wife2.setName("老婆2");husband.getWives().add(wife1);husband.getWives().add(wife2); // session.save(wife); session.save(husband);session.getTransaction().commit();session.close();} }
注解
package com.fuwh.model;import java.util.ArrayList; import java.util.List;import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany;import org.hibernate.annotations.GenericGenerator;@Entity(name="person") public class Person {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@ManyToMany(cascade=CascadeType.ALL)private List<Address> addresses=new ArrayList<Address>();public int getId() {return id;}public void setId(int id) {this.id = id;}public List<Address> getAddresses() {return addresses;}public void setAddresses(List<Address> addresses) {this.addresses = addresses;}}
package com.fuwh.model;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;import org.hibernate.annotations.GenericGenerator;@Entity(name="address") public class Address {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="street")private String street;private String number;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getStreet() {return street;}public void setStreet(String street) {this.street = street;}public String getNumber() {return number;}public void setNumber(String number) {this.number = number;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.model.Address; import com.fuwh.model.Person;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Person person=new Person();Address address1=new Address();address1.setNumber("1001");address1.setStreet("java路");Address address2=new Address();address2.setNumber("1002");address2.setStreet("php路");person.getAddresses().add(address1);person.getAddresses().add(address2);session.save(person);session.flush();//删除的时候会把所有的address的id的记录删除,在插入其他不用删除的 person.getAddresses().remove(address1);session.getTransaction().commit();session.close();} }
生成的SQL文
Hibernate: create table address (id integer not null auto_increment,number varchar(255),street varchar(255),primary key (id)) Hibernate: create table person (id integer not null auto_increment,primary key (id)) Hibernate: create table person_address (person_id integer not null,addresses_id integer not null) Hibernate: alter table person_address add constraint FKkvjdfs4jhjpxa6y3melormp0w foreign key (addresses_id) references address (id) Hibernate: alter table person_address add constraint FKnndfs0btabect8upo03uwgfxt foreign key (person_id) references person (id) Hibernate: insert intopersonvalues( ) Hibernate: insert intoaddress(number, street) values(?, ?) Hibernate: insert intoaddress(number, street) values(?, ?) Hibernate: insert intoperson_address(person_id, addresses_id) values(?, ?) Hibernate: insert intoperson_address(person_id, addresses_id) values(?, ?) Hibernate: delete fromperson_address whereperson_id=? Hibernate: insert intoperson_address(person_id, addresses_id) values(?, ?)
package com.fuwh.model;import java.util.HashSet; import java.util.Set;public class Wife {private int id;private String name;private Set<Husband> husbands=new HashSet<Husband>();public Set<Husband> getHusbands() {return husbands;}public void setHusbands(Set<Husband> husbands) {this.husbands = husbands;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!-- 这是实体类和表的映射关系的配置文件 --> <hibernate-mapping package="com.fuwh.model"><class name="Wife" table="t_wife"><id name="id" column="wifeId"><generator class="native"></generator></id><property name="name" column="wifeName"></property><!-- 这里必须参照Husband.hbm.xml文件中的连接表的配置,否则会默认生成两个连接表也就是两个单向的多对多 --><set name="husbands" inverse="true" table="husband_wife"><key column="wife_id"></key><many-to-many column="husband_id" class="com.fuwh.model.Husband" ></many-to-many></set></class></hibernate-mapping>
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.model.Child; import com.fuwh.model.Father; import com.fuwh.model.Husband; import com.fuwh.model.Wife;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Husband husband1=new Husband();husband1.setName("老公1");Husband husband2=new Husband();husband2.setName("老公2");Wife wife1=new Wife();wife1.setName("老婆1");Wife wife2=new Wife();wife2.setName("老婆2");husband1.getWives().add(wife1);husband1.getWives().add(wife2);wife1.getHusbands().add(husband1);wife1.getHusbands().add(husband2);session.save(husband1);session.save(husband2);session.getTransaction().commit();session.close();} }
生成的SQL文
Hibernate: create table husband_wife (husband_id integer not null,wife_id integer not null,primary key (husband_id, wife_id)) Hibernate: create table t_husband (husbandId integer not null auto_increment,husbandName varchar(255),primary key (husbandId)) Hibernate: create table t_wife (wifeId integer not null auto_increment,wifeName varchar(255),primary key (wifeId)) Hibernate: alter table husband_wife add constraint FK56txr9ocpn1k0eyc7ax1a2smw foreign key (wife_id) references t_wife (wifeId) Hibernate: alter table husband_wife add constraint FKsiwjiutn6eoha0iv059pd75fc foreign key (husband_id) references t_husband (husbandId) Hibernate: insert intot_husband(husbandName) values(?) Hibernate: insert intot_wife(wifeName) values(?) Hibernate: insert intot_husband(husbandName) values(?) Hibernate: insert intot_wife(wifeName) values(?)Hibernate: insert intohusband_wife(husband_id, wife_id) values(?, ?) Hibernate: insert intohusband_wife(husband_id, wife_id) values(?, ?)
注解
package com.fuwh.mtmbi;import java.util.ArrayList; import java.util.List;import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany;import org.hibernate.annotations.GenericGenerator;@Entity(name="person") public class Person {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@ManyToMany(cascade=CascadeType.ALL)private List<Address> addresses=new ArrayList<Address>();public int getId() {return id;}public void setId(int id) {this.id = id;}public List<Address> getAddresses() {return addresses;}public void setAddresses(List<Address> addresses) {this.addresses = addresses;}}
package com.fuwh.mtmbi;import java.util.ArrayList; import java.util.List;import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany;import org.hibernate.annotations.GenericGenerator;@Entity(name="address") public class Address {@Id@GeneratedValue(generator="_native")@GenericGenerator(name="_native",strategy="native")private int id;@Column(name="street")private String street;private String number;@ManyToMany(mappedBy="address")private List<Person> owners=new ArrayList<Person>();public int getId() {return id;}public void setId(int id) {this.id = id;}public String getStreet() {return street;}public void setStreet(String street) {this.street = street;}public String getNumber() {return number;}public void setNumber(String number) {this.number = number;}}
package com.fuwh.service;import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test;import com.fuwh.mtmbi.Person; import com.fuwh.mtmbi.Address;public class DoTest {//标准的sessionFactory取得方式private SessionFactory sessionFactory;@Beforepublic void setUp() throws Exception {final StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build();try {sessionFactory=new MetadataSources(registry).buildMetadata().buildSessionFactory();} catch (Exception e) {// TODO: handle exception e.printStackTrace();StandardServiceRegistryBuilder.destroy(registry);}}@Afterpublic void tearDown() throws Exception {if(sessionFactory != null){sessionFactory.close();}}@Testpublic void testAdd() {Session session=sessionFactory.openSession();session.beginTransaction();Person person1=new Person();Person person2=new Person();Address address1=new Address();address1.setNumber("101");Address address2=new Address();address2.setNumber("102");person1.getAddresses().add(address1);person1.getAddresses().add(address2);person2.getAddresses().add(address1);session.save(person1);session.save(person2);session.getTransaction().commit();session.close();} }
生成的SQL文
Hibernate: create table address (id integer not null auto_increment,number varchar(255),street varchar(255),primary key (id)) Hibernate: create table person (id integer not null auto_increment,primary key (id)) Hibernate: create table person_address (owners_id integer not null,addresses_id integer not null) Hibernate: alter table person_address add constraint FKkvjdfs4jhjpxa6y3melormp0w foreign key (addresses_id) references address (id) Hibernate: alter table person_address add constraint FKpts56mn8uttsyi3b63b2cihvo foreign key (owners_id) references person (id) Hibernate: insert intopersonvalues( ) Hibernate: insert intoaddress(number, street) values(?, ?) Hibernate: insert intoaddress(number, street) values(?, ?) Hibernate: insert intopersonvalues( ) Hibernate: insert intoperson_address(owners_id, addresses_id) values(?, ?) Hibernate: insert intoperson_address(owners_id, addresses_id) values(?, ?) Hibernate: insert intoperson_address(owners_id, addresses_id) values(?, ?)
转载于:https://www.cnblogs.com/zerotomax/p/6361633.html
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
相关文章
- SQL Server 数据库设计、命名、编码规范
2.简介 数据库设计是指对于一个给定的应用环境,构造最优的数据库模式,建立数据库及其应用系统,有效存储数据,满足用户信息要求和处理要求 数据库设计和开发标准是使Newegg Support Center的数据库系统的设计和开发正式化的标准。通过此标准,来规范数据库设计。 通过一致的…...
2024/4/17 4:12:12 - Typora--终于找到一个能够解决将csdn文章同步到hexo的完美编辑器(解决csdn图片防盗链导致无法直接复制文章的问题)。
文章目录需求背景新宠告诉我,我的名字叫什么?大声点我听不见~页面神奇之处看得见的优点如何设置项目根目录如何显示图片?于是最终操作流程 个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io 需求 能够将csdn的文章同步到自己的hexo博…...
2024/4/19 8:40:53 - spring通配符加载多个资源文件properties
4.4.1 使用路径通配符加载Resource 前面介绍的资源路径都是非常简单的一个路径匹配一个资源,Spring还提供了一种更强大的Ant模式通配符匹配,从能一个路径匹配一批资源。 Ant路径通配符支持“?”、“*”、“**”,注意通配符匹配不包括目录分隔符“/”: …...
2024/4/28 16:38:38 - C语言中static的作用
在C语言中,static的字面意思很容易把我们导入歧途,其实它的作用有三条。 (1)先来介绍它的第一条也是最重要的一条:隐藏。当我们同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性。为理解这句话,我举例来说明。我们要同时编译两个源文件,一个是a…...
2024/4/29 1:04:30 - 教程:ObjectPascal快速上手笔记01.
ObjectPascal快速入门笔记01注释:{ 花括号注释 };( 圆括号+星号注释(块注释) ); // 双斜杠注释(行注释); 不同形式注释可嵌套使用。对象命名:对大小写不敏感;不能带有空格; 第一个字母尽量不要带T(类)F(类中私有成员)I(接口);标识符:ASCII码字符集;任意长不带空格的字…...
2024/4/27 21:52:26 - 黑客工具大全
一、扫描工具Domain2.2-集WHOIS查询、上传页面批量检测、木马上传、数据库浏览及加密解密于一体!下载X-way 2.5-这也上一个非常不错的扫描器哦!功能非常多!使用也不难,入侵必备工具!下载SuperScan 3.0-强大的TCP 端口扫描器、Ping 和域名解析器!下载Namp 3.5-这个就厉害了,安全…...
2024/4/28 17:12:02 - Hibernate4学习总结(4)--注解形式的集合映射,关联关系映射
本文将接着上文,讲解hibernate4的集合映射的注解和关联关系映射的注解。本文包括两个部分: 集合映射的注解。关联关系映射的注解。一、集合映射的注解当持久化中有一个属性是集合(Set、List、Map),就要用到集合映射。集合属性会单独生成一张表。定义集合属性时面向接口,并且…...
2024/4/27 22:27:42 - 【小工具】CSDN博客导出工具-Java集成Maven开发
CSDN博客导出工具 之前一直想把CSDN的博客导入到自己的网站中,可是由于博客比较多,后面受朋友老郭启发,就找了个时间用Java开发了这款小工具。 转载请注明出处:http://chenhaoxiang.cn 本文源自【人生之旅_谙忆的博客】CSDNBlogExportCSDN博客导出工具之前一直想把CSDN的…...
2024/4/28 15:48:59 - private static与public static的用法及区别(Java)
其实,理解这两者的区别并不难,因为(public、private)和static这两种修饰符的作用本就不同,所以要理解两个的区别,其实就是这两种修饰符效果累加起来之后的区别。static:静态修饰符,被static修饰的变量和方法类似于全局变量和全局方法,可以在不创建对象时调用,当然也可…...
2024/4/27 23:25:37 - Android从资源文件中读取文件全
1. 相关文件夹介绍在Android项目文件夹里面,主要的资源文件是放在res文件夹里面的。assets文件夹是存放不进行编译加工的原生文件,即该文件夹里面的文件不会像xml,java文件被预编译,可以存放一些图片,html,js, css等文件。在后面会介绍如何读取assets文件夹的资源!res文…...
2024/4/28 3:35:44 - junit4 javaee 5.0 jpa SSH 单元测试问题集锦
本篇文章基于已经实现了ssh集成的demo、项目。具体的ssh项目怎么配置,请参考本文最后spring环境下的JUnit4测试1,下载所需jar包:spring-test-3.2.0.RELEASE.jarjunit-4.11.jarcommons-dbcp-1.4.jar jar包怎么下载? junit4测试 和 ssh 集成测试分两种, 一种是比较老点的手动…...
2024/4/28 2:10:31 - pascal语言入门
Pascal语言初印象 一、认识程序 Pascal语言,语法清晰,语句直接。 最简单的程序不过两行。 begin end. 下面我们借用A+B问题来认识一下pascal的基本框架。var a,b:real; begin read(a,b); write(a+b); end. 诶,这几个单词好像长得很熟悉?除了第一个单词。 通过看英文…...
2024/4/28 6:21:07 - Pascal基础教程
第一课 初识Pascal语言信息学奥林匹克竞赛是一项益智性的竞赛活动,核心是考查选手的智力和使用计算机解题的能力。选手首先应针对竞赛中题目的要求构建数学模型,进而构造出计算机可以接受的算法,之后要写出高级语言程序,上机调试通过。程序设计是信息学奥林匹克竞赛的基本…...
2024/4/27 21:50:15 - TypedValue.applyDimension 中dp和sp之间转化的真相
最近在看了许多关于dp-px,px-dp,sp-px,px-sp之间转化的博文,过去我比较常用的方式是:1 //转换dip为px 2 public static int convertDipOrPx(Context context, int dip) { 3 float scale = context.getResources().getDisplayMetrics().density; 4 return (int)(dip…...
2024/4/28 7:36:23 - Java中Static执行顺序
什么是staticstatic方法就是没有this的方法。在static方法内部不能调用非静态方法,反过来是可以的。而且可以在没有创建任何对象的前提下,仅仅通过类本身来调用static方法。也就是说说被static关键字修饰的方法或者变量不需要依赖于对象来进行访问,只要类被加载了,就可以通…...
2024/4/28 22:06:09 - 百度mp3批量下载器 v1.0.2.5 绿色不要注册
百度mp3批量下载器 v1.0.2.5 绿色不要注册百度mp3批量下载器下载百度音乐排行榜,百度音乐掌门人中的歌曲,操作非常简单,下载过程自动化,免去了在网页上多次点击链接才能下载一首歌曲的痛苦。百度mp3批量下载器软件特色: 一键下载百度mp3 top500歌曲排行榜 同步下载动态…...
2024/4/28 3:46:18 - Pascal教程
第一章 简单程序 2第一节 Pascal 程序结构和基本语句 2第二节 顺序结构程序与基本数据类型 6第二章 分支程序 10第一节 条件语句与复合语句 10第二节 情况语句与算术标准函数 12第三章 循环程序 16第一节 for 循环 16第二节 repeat 循环 22第三节 While 循环 27第四章…...
2024/4/28 5:45:37 - 深入理解多态,为什么说静态成员无多态特性?
这是前不久做的一道关于静态成员与静态方法特性的题,真的不做下题都不知道自己的基础究竟是有多浅薄,当然这里指对多态的理解一、先回顾下静态成员与静态变量吧,static关键字参考书籍《Java编程思想》 参考博客Java中static作用及用法详解 我们知道,作为面向对象设计的明…...
2024/4/28 19:48:34 - VIP账号共享
希望有人共享csdn的VIP账号 我想下载一些资料,可是没有积分,网上的免积分下载器都是骗人的,希望csdn的爱心大佬能分享一下VIP账号供像我一样有需要的人,感激不尽。...
2024/4/27 21:30:26 - Android错误解决 Call requires API level 3 (current min is 1): android.opengl.GLSurfaceView#getResources
今天用Android开发OpenGL es时报了一个错误:Call requires API level 3 (current min is 1): android.opengl.GLSurfaceView#getResources 哎哟~难受死我了,代码是一点错也没有啊~ 找来找去也找不到 仔仔细细眼睛看花了都找不到错误,原来是,系统BUG,暂且这么理解吧 就是嘛…...
2024/4/28 16:52:48
最新文章
- 【JavaScript】let,const 和 var 的区别
作用域: var 声明的变量具有全局作用域和函数作用域,可以跨块访问。let 和 const 声明的变量还具有块级作用域,意味着它们在声明它们的块(例如,if 块、for 块、函数块等)内可见。(之前没有块作用…...
2024/5/1 5:38:58 - 梯度消失和梯度爆炸的一些处理方法
在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言,在此感激不尽。 权重和梯度的更新公式如下: w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...
2024/3/20 10:50:27 - ChatGPT 初学者指南
原文:ChatGPT for Beginners 译者:飞龙 协议:CC BY-NC-SA 4.0 介绍 如果您一直关注新闻和趋势,您可能已经在某个地方读到或听到过,Sam Altman 的生成式人工智能平台 ChatGPT 已经将人工智能推向了一个新的高度 - 许多…...
2024/4/30 2:06:42 - promise.all方式使用
romise.all( ).then( ) 处理多个异步任务,且所有的异步任务都得到结果时的情况。 比如:用户点击按钮,会弹出一个弹出对话框,对话框中有两部分数据呈现,这两部分数据分别是不同的后端接口获取的数据。 弹框弹出后的初…...
2024/4/30 5:11:30 - 【外汇早评】美通胀数据走低,美元调整
原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...
2024/4/29 23:16:47 - 【原油贵金属周评】原油多头拥挤,价格调整
原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...
2024/4/30 18:14:14 - 【外汇周评】靓丽非农不及疲软通胀影响
原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...
2024/4/29 2:29:43 - 【原油贵金属早评】库存继续增加,油价收跌
原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...
2024/4/30 18:21:48 - 【外汇早评】日本央行会议纪要不改日元强势
原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...
2024/4/27 17:58:04 - 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响
原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...
2024/4/27 14:22:49 - 【外汇早评】美欲与伊朗重谈协议
原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...
2024/4/28 1:28:33 - 【原油贵金属早评】波动率飙升,市场情绪动荡
原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...
2024/4/30 9:43:09 - 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试
原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...
2024/4/27 17:59:30 - 【原油贵金属早评】市场情绪继续恶化,黄金上破
原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...
2024/4/25 18:39:16 - 【外汇早评】美伊僵持,风险情绪继续升温
原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...
2024/4/28 1:34:08 - 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势
原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...
2024/4/26 19:03:37 - 氧生福地 玩美北湖(上)——为时光守候两千年
原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...
2024/4/29 20:46:55 - 氧生福地 玩美北湖(中)——永春梯田里的美与鲜
原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...
2024/4/30 22:21:04 - 氧生福地 玩美北湖(下)——奔跑吧骚年!
原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...
2024/5/1 4:32:01 - 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!
原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...
2024/4/27 23:24:42 - 「发现」铁皮石斛仙草之神奇功效用于医用面膜
原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...
2024/4/28 5:48:52 - 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者
原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...
2024/4/30 9:42:22 - 广州械字号面膜生产厂家OEM/ODM4项须知!
原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...
2024/4/30 9:43:22 - 械字号医用眼膜缓解用眼过度到底有无作用?
原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...
2024/4/30 9:42:49 - 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...
解析如下:1、长按电脑电源键直至关机,然后再按一次电源健重启电脑,按F8健进入安全模式2、安全模式下进入Windows系统桌面后,按住“winR”打开运行窗口,输入“services.msc”打开服务设置3、在服务界面,选中…...
2022/11/19 21:17:18 - 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。
%读入6幅图像(每一幅图像的大小是564*564) f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...
2022/11/19 21:17:16 - 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...
win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面,在等待界面中我们需要等待操作结束才能关机,虽然这比较麻烦,但是对系统进行配置和升级…...
2022/11/19 21:17:15 - 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...
有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows,请勿关闭计算机”的提示,要过很久才能进入系统,有的用户甚至几个小时也无法进入,下面就教大家这个问题的解决方法。第一种方法:我们首先在左下角的“开始…...
2022/11/19 21:17:14 - win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...
置信有很多用户都跟小编一样遇到过这样的问题,电脑时发现开机屏幕显现“正在配置Windows Update,请勿关机”(如下图所示),而且还需求等大约5分钟才干进入系统。这是怎样回事呢?一切都是正常操作的,为什么开时机呈现“正…...
2022/11/19 21:17:13 - 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...
Win7系统开机启动时总是出现“配置Windows请勿关机”的提示,没过几秒后电脑自动重启,每次开机都这样无法进入系统,此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一:开机按下F8,在出现的Windows高级启动选…...
2022/11/19 21:17:12 - 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...
有不少windows10系统用户反映说碰到这样一个情况,就是电脑提示正在准备windows请勿关闭计算机,碰到这样的问题该怎么解决呢,现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法:1、2、依次…...
2022/11/19 21:17:11 - 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...
今天和大家分享一下win7系统重装了Win7旗舰版系统后,每次关机的时候桌面上都会显示一个“配置Windows Update的界面,提示请勿关闭计算机”,每次停留好几分钟才能正常关机,导致什么情况引起的呢?出现配置Windows Update…...
2022/11/19 21:17:10 - 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...
只能是等着,别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚,只能是考虑备份数据后重装系统了。解决来方案一:管理员运行cmd:net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...
2022/11/19 21:17:09 - 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?
原标题:电脑提示“配置Windows Update请勿关闭计算机”怎么办?win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢?一般的方…...
2022/11/19 21:17:08 - 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...
关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!关机提示 windows7 正在配…...
2022/11/19 21:17:05 - 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...
钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...
2022/11/19 21:17:05 - 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...
前几天班里有位学生电脑(windows 7系统)出问题了,具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面,长时间没反应,无法进入系统。这个问题原来帮其他同学也解决过,网上搜了不少资料&#x…...
2022/11/19 21:17:04 - 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...
本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法,并在最后教给你1种保护系统安全的好方法,一起来看看!电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中,添加了1个新功能在“磁…...
2022/11/19 21:17:03 - 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...
许多用户在长期不使用电脑的时候,开启电脑发现电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机。。.这要怎么办呢?下面小编就带着大家一起看看吧!如果能够正常进入系统,建议您暂时移…...
2022/11/19 21:17:02 - 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...
配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!配置windows update失败 还原更改 请勿关闭计算机&#x…...
2022/11/19 21:17:01 - 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...
不知道大家有没有遇到过这样的一个问题,就是我们的win7系统在关机的时候,总是喜欢显示“准备配置windows,请勿关机”这样的一个页面,没有什么大碍,但是如果一直等着的话就要两个小时甚至更久都关不了机,非常…...
2022/11/19 21:17:00 - 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...
当电脑出现正在准备配置windows请勿关闭计算机时,一般是您正对windows进行升级,但是这个要是长时间没有反应,我们不能再傻等下去了。可能是电脑出了别的问题了,来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...
2022/11/19 21:16:59 - 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...
我们使用电脑的过程中有时会遇到这种情况,当我们打开电脑之后,发现一直停留在一个界面:“配置Windows Update失败,还原更改请勿关闭计算机”,等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢࿰…...
2022/11/19 21:16:58 - 如何在iPhone上关闭“请勿打扰”
Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...
2022/11/19 21:16:57