Hibernate实战(第二版)笔记----第四章--映射持久化类

2024-06-17 05:48

本文主要是介绍Hibernate实战(第二版)笔记----第四章--映射持久化类,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、本章主要介绍了


实体类型: 


该类的实例有OID,一个实例对应表的一条记录,实例的OID就是该记录的主键。 
一个实例可以被多个其他实体对象共享引用。 有独立的生命周期。可以被单独持久化。 


值类型 :没有OID,不能被单独持久化,只能附属到一个依赖对象上,只能被依赖对象引用,有该依赖对象负责其生命周期。(没有OID就是没有主键,当然不能insert到表中了)。 


一句话: 


实体类型,在DB中代表一个表,一个实体代表一行记录;

值类型在DB中没有表,只代表一个column。 


对象模型(域模型)有具体的程序代码写成的,为了提高代码的重用性,可能会把域模型拆分定义成多个类,在这多个类中,那些包含了主键的成员的类就是entity,它的OID对应的就是表中的主键,它可以直接单独insert到表中;而那些只对应包含非主键的成员变量的类,就是值类.值类作为成员变量定义在entity类中,持久化entity类时,entity实例被保存成一个row,它的值类成员被保存成row的column。


几种键


键: 键是唯一标识一个实体的一个或者多个数据属性。在物理数据库中,键可以由表的一个或者多个列组成,它们的值唯一标识关系表中的一行。


复合键: 由两个或者多个属性组成的键。


自然键: 由现实世界中已经存在的属性组成的键。例如,美国公民被分配了一个唯一(不保证一定正确,但实际上非常接近唯一)的社会保险号(SSN)。如果隐私法允许的话,SSN可能被用作Person实体的自然键(假设组织的人员范围仅限于美国)。


代理键: 完全没有商业含义,通常由当下的系统自动生成,都是单键。


自然键: 已经真实存在的键,通常具有商业含义,比如身份证ID,护照编码等等,可以是单键,也可以是复合键。


候选键: 在逻辑数据模型中的实体类型可能具有0或多个候选键,简称为唯一标识(注解:某些人不主张在逻辑数据模型中标识候选键,因此没有固定标准)。例如,假设我们只涉及美国公民,那么SSN是Person实体类型的一个候选键,同时姓名与电话号码的组合(假设组合是唯一的)是第二个可能的候选键。这两个键都被称作候选键是因为它们是物理数据模型中主键、次键或者非键的候选目标。

主键: 实体类型的首选键。


备用键: 也就是次键,是表中行的另一个唯一标识。


外键: 在一个实体类型中表示另一个实体类型的主键或者次键的一个或多个属性。


详解介绍参考这:https://ask.hellobi.com/blog/rayshawn/3257



二、代码


一些实体类:




其中User类中使用了作为包级别元数据配置的Hibernate标识符生成器:


package org.jpwh.model.advanced;import org.jpwh.model.Constants;import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;@Entity
@Table(name = "USERS")
public class User {@Id@GeneratedValue(generator = Constants.ID_GENERATOR)protected Long id;public Long getId() {return id;}protected Address address;public Address getAddress() {return address;}public void setAddress(Address address) {this.address = address;}
}


ID_GENERATOR定义为:


/model/src/main/java/org/jpwh/model/package-info.java

@org.hibernate.annotations.GenericGenerator(name = "ID_GENERATOR",strategy = "enhanced-sequence",parameters = {@org.hibernate.annotations.Parameter(name = "sequence_name",value = "JPWH_SEQUENCE"),@org.hibernate.annotations.Parameter(name = "initial_value",value = "1000")
})
package org.jpwh.model;

而ItemBidSummary类则使用了子查询映射:

package org.jpwh.model.advanced;import javax.persistence.Entity;
import javax.persistence.Id;@Entity
@org.hibernate.annotations.Immutable
@org.hibernate.annotations.Subselect(value = "select i.ID as ITEMID, i.ITEM_NAME as NAME, " +"count(b.ID) as NUMBEROFBIDS " +"from ITEM i left outer join BID b on i.ID = b.ITEM_ID " +"group by i.ID, i.ITEM_NAME"
)// TODO Table names are case sensitive, Hibernate bug HHH-8430
@org.hibernate.annotations.Synchronize({"Item", "Bid"})
public class ItemBidSummary {@Idprotected Long itemId;protected String name;protected long numberOfBids;public ItemBidSummary() {}// Getter methods...public Long getItemId() {return itemId;}public String getName() {return name;}public long getNumberOfBids() {return numberOfBids;}// ...
}


测试类:


/examples/src/test/java/org/jpwh/test/advanced/MappedSubselect.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.jpwh.model.advanced.ItemBidSummary;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;import static org.testng.Assert.assertEquals;//映射子查询
public class MappedSubselect extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void loadSubselectEntity() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();{ItemBidSummary itemBidSummary = em.find(ItemBidSummary.class, ITEM_ID);// select * from (//      select i.ID as ITEMID, i.ITEM_NAME as NAME, ...// ) where ITEMID = ?assertEquals(itemBidSummary.getName(), "AUCTION: Some item");}em.clear();{ // Hibernate将在查询之前同步正确的表Item item = em.find(Item.class, ITEM_ID);item.setName("New name");// 在检索标识符之前不刷新!// ItemBidSummary itemBidSummary = em.find(ItemBidSummary.class, ITEM_ID);// 如果同步表受影响,在查询之前自动刷新。Query query = em.createQuery("select ibs from ItemBidSummary ibs where ibs.itemId = :id");ItemBidSummary itemBidSummary =(ItemBidSummary)query.setParameter("id", ITEM_ID).getSingleResult();assertEquals(itemBidSummary.getName(), "AUCTION: New name");}tx.commit();em.close();} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}

/examples/src/test/java/org/jpwh/test/advanced/AccessType.java
package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;import static org.testng.Assert.assertEquals;public class AccessType extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadAccessType() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getName(), "AUCTION: Some item");tx.commit();em.close();} finally {TM.rollback();}}}


/examples/src/test/java/org/jpwh/test/advanced/BooleanOverride.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;import static org.testng.Assert.assertTrue;public class BooleanOverride extends JPATest {@BeforeClass@java.lang.Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadOverride() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");someItem.setVerified(true);em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertTrue(item.isVerified());tx.commit();em.close();} finally {TM.rollback();}}}


/examples/src/test/java/org/jpwh/test/advanced/DerivedProperties.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;import static org.testng.Assert.assertEquals;//派生属性
public class DerivedProperties extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadFormula() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getShortDescription(), "This is some...");tx.commit();em.close();} finally {TM.rollback();}}@Testpublic void storeLoadFormulaSubselect() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getAverageBidAmount().compareTo(new BigDecimal("12")), 0);tx.commit();em.close();} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}

/examples/src/test/java/org/jpwh/test/advanced/GeneratedProperties.java

package org.jpwh.test.advanced;import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.jpwh.env.DatabaseProduct;
import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;import static org.testng.Assert.*;//生成的属性
public class GeneratedProperties extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Overridepublic void afterJPABootstrap() throws Exception {if (!TM.databaseProduct.equals(DatabaseProduct.H2)) return;// LASTMODIFIED测试显示数据库触发器如何生成属性值,我们实际上需要一个触发器try (Session session = JPA.createEntityManager().unwrap(Session.class)) {session.doWork(new Work() {@Overridepublic void execute(Connection connection) throws SQLException {Statement stat = connection.createStatement();stat.execute("drop trigger if exists TRG_ITEM_LASTMODIFIED_INSERT");stat.execute("create trigger TRG_ITEM_LASTMODIFIED_INSERT after insert on ITEM" +" for each row call \"" + org.jpwh.shared.trigger.UpdateLastModifiedTrigger.class.getName() + "\"");stat.execute("drop trigger if exists TRG_ITEM_LASTMODIFIED_UPDATE");stat.execute("create trigger TRG_ITEM_LASTMODIFIED_UPDATE after update on ITEM" +" for each row call \"" + org.jpwh.shared.trigger.UpdateLastModifiedTrigger.class.getName() + "\"");stat.close();}});}}@Test(groups = {"H2"})public void storeLoadLastModified() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertNotNull(item.getCreatedOn());Date lastModified = item.getLastModified();assertNotNull(lastModified);assertTrue(item.getCreatedOn().getTime() < lastModified.getTime());item.setDescription("Some modification.");em.flush();Date newLastModified = item.getLastModified();assertNotEquals(lastModified, newLastModified, "Modification time should have been updated");tx.commit();em.close();} finally {TM.rollback();}}@Testpublic void storeLoadInitialPrice() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);tx.commit();em.close();assertEquals(item.getInitialPrice().compareTo(new BigDecimal("1")), 0);} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}


/examples/src/test/java/org/jpwh/test/advanced/LazyProperties.java

package org.jpwh.test.advanced;import org.hibernate.Session;
import org.hibernate.engine.jdbc.StreamUtils;
import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.sql.Blob;
import java.util.Random;import static org.testng.Assert.assertEquals;public class LazyProperties extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadProperties() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");byte[] bytes = new byte[131072];new Random().nextBytes(bytes);someItem.setImage(bytes);em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);// Accessing one initializes ALL lazy properties in a single SELECTassertEquals(item.getDescription(), "This is some description.");assertEquals(item.getImage().length, 131072); // 128 kilobytestx.commit();em.close();} finally {TM.rollback();}}@Testpublic void storeLoadLocator() throws Exception {// TODO: This test fails on H2 standalone// http://groups.google.com/group/h2-database/browse_thread/thread/9c6f4893a62c9b1aUserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();byte[] bytes = new byte[131072];new Random().nextBytes(bytes);InputStream imageInputStream = new ByteArrayInputStream(bytes);int byteLength = bytes.length;Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");// Need the native Hibernate APISession session = em.unwrap(Session.class);// You need to know the number of bytes you want to read from the stream!Blob blob = session.getLobHelper().createBlob(imageInputStream, byteLength);someItem.setImageBlob(blob);em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);// You can stream the bytes directly...InputStream imageDataStream = item.getImageBlob().getBinaryStream();// ... or materialize them into memory:ByteArrayOutputStream outStream = new ByteArrayOutputStream();StreamUtils.copy(imageDataStream, outStream);byte[] imageBytes = outStream.toByteArray();assertEquals(imageBytes.length, 131072);tx.commit();em.close();} finally {TM.rollback();}}}

/examples/src/test/java/org/jpwh/test/advanced/NestedComponents.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Address;
import org.jpwh.model.advanced.City;
import org.jpwh.model.advanced.User;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.util.Locale;import static org.testng.Assert.assertEquals;//嵌套组件
public class NestedComponents extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeAndLoadUsers() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();City city = new City();city.setZipcode("12345");city.setName("Some City");city.setCountry(Locale.GERMANY.getCountry());Address address = new Address();address.setStreet("Some Street 123");address.setCity(city);User userOne = new User();userOne.setAddress(address);em.persist(userOne);tx.commit();em.close();tx.begin();em = JPA.createEntityManager();User u = em.find(User.class, userOne.getId());assertEquals(u.getAddress().getStreet(), "Some Street 123");assertEquals(u.getAddress().getCity().getZipcode(), "12345");assertEquals(u.getAddress().getCity().getCountry(), Locale.GERMANY.getCountry());tx.commit();em.close();} finally {TM.rollback();}}}

/examples/src/test/java/org/jpwh/test/advanced/Temporal.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;import static org.testng.Assert.*;//临时的
public class Temporal extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadTemporal() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");// someItem.setReviewedOn(Instant.now().plusSeconds(60)); // A future timeem.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();Date ORIGINAL_CREATION_DATE = someItem.getCreatedOn();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);// java.util.Date and java.sql.Timestamp are not symmetric!assertFalse(item.getCreatedOn().equals(ORIGINAL_CREATION_DATE));assertFalse(item.getCreatedOn().getClass().equals(ORIGINAL_CREATION_DATE.getClass()));// 这是如何正确比较Java中的时间值...assertEquals(ORIGINAL_CREATION_DATE.getTime(), item.getCreatedOn().getTime());// 或者使用稍微令人讨厌但相当可怕的日历APICalendar oldDate = new GregorianCalendar();oldDate.setTime(ORIGINAL_CREATION_DATE);Calendar newDate = new GregorianCalendar();newDate.setTime(item.getCreatedOn());assertEquals(oldDate, newDate);// Or the Java 8 API// assertTrue(item.getReviewedOn().isAfter(item.getCreatedOn().toInstant()));tx.commit();em.close();} finally {TM.rollback();}}}

/examples/src/test/java/org/jpwh/test/advanced/TransformingColumns.java

package org.jpwh.test.advanced;import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;//转换列
public class TransformingColumns extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadTransform() throws Exception {final long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();{Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getMetricWeight(), 2.0);final boolean[] tests = new boolean[1];em.unwrap(Session.class).doWork(new Work() {@Overridepublic void execute(Connection connection) throws SQLException {PreparedStatement statement = null;ResultSet result = null;try {statement = connection.prepareStatement("select IMPERIALWEIGHT from ITEM where ID = ?");statement.setLong(1, ITEM_ID);result = statement.executeQuery();while (result.next()) {Double imperialWeight = result.getDouble("IMPERIALWEIGHT");assertEquals(imperialWeight, 4.40924);tests[0] = true;}} finally {if (result != null)result.close();if (statement != null)statement.close();}}});assertTrue(tests[0]);}em.clear();{List<Item> result =em.createQuery("select i from Item i where i.metricWeight = :w").setParameter("w", 2.0).getResultList();assertEquals(result.size(), 1);}em.clear();tx.commit();em.close();} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setMetricWeight(2);item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}


这篇关于Hibernate实战(第二版)笔记----第四章--映射持久化类的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1068631

相关文章

Tolua使用笔记(上)

目录   1.准备工作 2.运行例子 01.HelloWorld:在C#中,创建和销毁Lua虚拟机 和 简单调用。 02.ScriptsFromFile:在C#中,对一个lua文件的执行调用 03.CallLuaFunction:在C#中,对lua函数的操作 04.AccessingLuaVariables:在C#中,对lua变量的操作 05.LuaCoroutine:在Lua中,

AssetBundle学习笔记

AssetBundle是unity自定义的资源格式,通过调用引擎的资源打包接口对资源进行打包成.assetbundle格式的资源包。本文介绍了AssetBundle的生成,使用,加载,卸载以及Unity资源更新的一个基本步骤。 目录 1.定义: 2.AssetBundle的生成: 1)设置AssetBundle包的属性——通过编辑器界面 补充:分组策略 2)调用引擎接口API

持久层 技术选型如何决策?JPA,Hibernate,ibatis(mybatis)

转自:http://t.51jdy.cn/thread-259-1-1.html 持久层 是一个项目 后台 最重要的部分。他直接 决定了 数据读写的性能,业务编写的复杂度,数据结构(对象结构)等问题。 因此 架构师在考虑 使用那个持久层框架的时候 要考虑清楚。 选择的 标准: 1,项目的场景。 2,团队的技能掌握情况。 3,开发周期(开发效率)。 传统的 业务系统,通常业

《offer来了》第二章学习笔记

1.集合 Java四种集合:List、Queue、Set和Map 1.1.List:可重复 有序的Collection ArrayList: 基于数组实现,增删慢,查询快,线程不安全 Vector: 基于数组实现,增删慢,查询快,线程安全 LinkedList: 基于双向链实现,增删快,查询慢,线程不安全 1.2.Queue:队列 ArrayBlockingQueue:

React+TS前台项目实战(十七)-- 全局常用组件Dropdown封装

文章目录 前言Dropdown组件1. 功能分析2. 代码+详细注释3. 使用方式4. 效果展示 总结 前言 今天这篇主要讲全局Dropdown组件封装,可根据UI设计师要求自定义修改。 Dropdown组件 1. 功能分析 (1)通过position属性,可以控制下拉选项的位置 (2)通过传入width属性, 可以自定义下拉选项的宽度 (3)通过传入classN

操作系统实训复习笔记(1)

目录 Linux vi/vim编辑器(简单) (1)vi/vim基本用法。 (2)vi/vim基础操作。 进程基础操作(简单) (1)fork()函数。 写文件系统函数(中等) ​编辑 (1)C语言读取文件。 (2)C语言写入文件。 1、write()函数。  读文件系统函数(简单) (1)read()函数。 作者本人的操作系统实训复习笔记 Linux

LVGL快速入门笔记

目录 一、基础知识 1. 基础对象(lv_obj) 2. 基础对象的大小(size) 3. 基础对象的位置(position) 3.1 直接设置方式 3.2 参照父对象对齐 3.3 获取位置 4. 基础对象的盒子模型(border-box) 5. 基础对象的样式(styles) 5.1 样式的状态和部分 5.1.1 对象可以处于以下状态States的组合: 5.1.2 对象

DDS信号的发生器(验证篇)——FPGA学习笔记8

前言:第一部分详细讲解DDS核心框图,还请读者深入阅读第一部分,以便理解DDS核心思想 三刷小梅哥视频总结! 小梅哥https://www.corecourse.com/lander 一、DDS简介         DDS(Direct Digital Synthesizer)即数字合成器,是一种新型的频率合成技术,具有低成本、低功耗、高分辨率、频率转换时间短、相位连续性好等优点,对数字信

数据库原理与安全复习笔记(未完待续)

1 概念 产生与发展:人工管理阶段 → \to → 文件系统阶段 → \to → 数据库系统阶段。 数据库系统特点:数据的管理者(DBMS);数据结构化;数据共享性高,冗余度低,易于扩充;数据独立性高。DBMS 对数据的控制功能:数据的安全性保护;数据的完整性检查;并发控制;数据库恢复。 数据库技术研究领域:数据库管理系统软件的研发;数据库设计;数据库理论。数据模型要素 数据结构:描述数据库

【软考】信息系统项目管理师(高项)备考笔记——信息系统项目管理基础

信息系统项目管理基础 日常笔记 项目的特点:临时性(一次性)、独特的产品、服务或成果、逐步完善、资源约束、目的性。 临时性是指每一个项目都有确定的开始和结束日期独特性,创造独特的可交付成果,如产品、服务或成果逐步完善意味着分步、连续的积累。例如,在项目早期,项目范围的说明是粗略的,随着项目团队对目标和可交付成果的理解更完整和深入时,项目的范围也就更具体和详细。 战略管理包括以下三个过程