最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JPA如何將查詢結(jié)果轉(zhuǎn)換為DTO對(duì)象

 更新時(shí)間:2022年02月23日 09:47:54   作者:itlgl  
這篇文章主要介紹了JPA如何將查詢結(jié)果轉(zhuǎn)換為DTO對(duì)象,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

前言

JPA支持使用@Query自定義查詢,查詢的結(jié)果需要字節(jié)用DTO對(duì)象接收,如果使用HQL的查詢語句,可以將直接將DTO對(duì)象的構(gòu)造方法傳入hql中,直接轉(zhuǎn)為DTO對(duì)象;而如果使用native sql查詢的方式,只能將返回結(jié)果用Object[]對(duì)象接收,然后DTO設(shè)置對(duì)象的構(gòu)造來接收Object[]里面的參數(shù)完成DTO對(duì)象的轉(zhuǎn)換。

例子

mysql數(shù)據(jù)庫(kù)表

用戶表

CREATE TABLE `pos_user` (
? `id` bigint(20) NOT NULL AUTO_INCREMENT,
? `user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
? `user_pwd` varchar(255) DEFAULT NULL,
? `user_type` int(11) DEFAULT NULL,
? `parent_id` bigint(20) DEFAULT NULL,
? `user_status` int(11) DEFAULT NULL,
? `distributor_id` bigint(20) DEFAULT NULL,
? `creator_identity_type` int(2) DEFAULT NULL,
? `creator_id` bigint(20) DEFAULT NULL,
? `create_date` varchar(50) DEFAULT NULL,
? PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;

設(shè)備表

CREATE TABLE `pos_device` (
? `id` bigint(20) NOT NULL AUTO_INCREMENT,
? `imei` varchar(120) NOT NULL,
? `mac` varchar(120) NOT NULL,
? `unique_code` varchar(120) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
? `type` varchar(100) DEFAULT NULL,
? `system_version` varchar(100) DEFAULT NULL,
? `distributor_id` bigint(20) DEFAULT NULL,
? `creator_identity_type` int(2) DEFAULT NULL,
? `creator_id` bigint(20) DEFAULT NULL,
? `create_date` varchar(50) DEFAULT NULL,
? PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;

用戶和設(shè)備關(guān)聯(lián)表

CREATE TABLE `pos_user_device_relation` (
? `id` bigint(20) NOT NULL AUTO_INCREMENT,
? `device_id` bigint(20) DEFAULT NULL,
? `user_id` bigint(20) DEFAULT NULL,
? PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

可以看到用戶和設(shè)備關(guān)聯(lián)表中有用戶id和設(shè)備id

聯(lián)合查詢的需求

想列出pos_user_device_relation表中所有pos_user的distributor_id=1的所有用戶和設(shè)備,要求返回的信息包括用戶的username、type信息和設(shè)備的imei、mac等信息。

sql語句

SELECT
pdr.id,
pdr.device_id,
pd.imei,
pd.mac,
pd.unique_code,
pd.type,
pd.system_version,
pdr.user_id,
pu.user_name,
pu.user_type
FROM
pos_user_device_relation pdr, pos_user pu, pos_device pd
WHERE pdr.device_id = pd.id AND pdr.user_id = pu.id AND pdr.user_id in (select id from pos_user where distributor_id=1) limit 0,10

查詢可以正常得到結(jié)果,結(jié)果行是這樣的:

+----+-----------+---------------------+-------------------+--------------------------+----------+----------------+---------+---------------+-----------+
| id | device_id | imei                | mac               | unique_code              | type     | system_version | user_id | user_name     | user_type |
+----+-----------+---------------------+-------------------+--------------------------+----------+----------------+---------+---------------+-----------+

如何在JPA中映射為DTO對(duì)象

DTO對(duì)象字段定義如下:

private Long posUserDeviceId;
private Long deviceId;
private String deviceImei;
private String deviceMac;
private String deviceUniqueCode;
private String deviceType;
private String deviceSystemVersion;
private Long userId;
private String username;
private PosUserEntityConstants.UserType userType;

對(duì)象中的PosUserEntityConstants.UserType是一個(gè)自定義轉(zhuǎn)換類型,通過繼承AttributeConverter將Integer轉(zhuǎn)換為UserType的枚舉。

方法一:使用HQL的方法

Repository的查詢代碼如下:

@Query(
? ? ? ? value = "SELECT\n" +
? ? ? ? ? ? ? ? "new com.hengbao.ethiopiatelecomrecharge.dao.dto.PosUserDeviceRelationDto(\n" +
? ? ? ? ? ? ? ? "pdr.id,\n" +
? ? ? ? ? ? ? ? "pdr.deviceId,\n" +
? ? ? ? ? ? ? ? "pd.imei,\n" +
? ? ? ? ? ? ? ? "pd.mac,\n" +
? ? ? ? ? ? ? ? "pd.uniqueCode,\n" +
? ? ? ? ? ? ? ? "pd.type,\n" +
? ? ? ? ? ? ? ? "pd.systemVersion,\n" +
? ? ? ? ? ? ? ? "pdr.userId,\n" +
? ? ? ? ? ? ? ? "pu.userName,\n" +
? ? ? ? ? ? ? ? "pu.userType\n" +
? ? ? ? ? ? ? ? ") \n" +
? ? ? ? ? ? ? ? "FROM \n" +
? ? ? ? ? ? ? ? "PosUserDeviceRelationEntity pdr, PosUserEntity pu, PosDeviceEntity pd \n" +
? ? ? ? ? ? ? ? "WHERE pdr.deviceId = pd.id AND pdr.userId = pu.id AND pdr.userId in (select id from PosUserEntity where distributorId=?1)",
? ? ? ? countQuery = "SELECT count(*) FROM \n" +
? ? ? ? ? ? ? ? "PosUserDeviceRelationEntity pdr, PosUserEntity pu, PosDeviceEntity pd \n" +
? ? ? ? ? ? ? ? "WHERE pdr.deviceId = pd.id AND pdr.userId = pu.id AND pdr.userId in (select id from PosUserEntity where distributorId=?1)"
)
Page<PosUserDeviceRelationDto> findUserAndDeviceInfoByDistributorId(Long distributorId, Pageable pageable);

可以看到HQL的方法將PosUserDeviceRelationDto的構(gòu)造器直接傳入到HQL語句中,省去了我們自行轉(zhuǎn)換的麻煩。那么PosUserDeviceRelationDto中也要重寫一個(gè)相應(yīng)的構(gòu)造器:

由于項(xiàng)目中使用了lombok,所有最終dto的代碼只是在類上面加上了一些注解,@AllArgsConstructor的注解會(huì)自動(dòng)生成一個(gè)全參數(shù)的構(gòu)造器,構(gòu)造器的順序和字段定義順序一致,類代碼如下:

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class PosUserDeviceRelationDto implements Serializable {
? ? /**
? ? ?* 版本號(hào)
? ? ?*/
? ? private static final long serialVersionUID = 1L;?
? ? private Long posUserDeviceId;?
? ? private Long deviceId;
? ? private String deviceImei;
? ? private String deviceMac;
? ? private String deviceUniqueCode;
? ? private String deviceType;
? ? private String deviceSystemVersion;?
? ? private Long userId;
? ? private String username;
? ? private PosUserEntityConstants.UserType userType;
}

方法二:使用native query的方式查詢并轉(zhuǎn)換為dto

Repository的查詢代碼如下:

@Query(
? ? ? ? value = "SELECT\n" +
? ? ? ? ? ? ? ? "pdr.id,\n" +
? ? ? ? ? ? ? ? "pdr.device_id,\n" +
? ? ? ? ? ? ? ? "pd.imei,\n" +
? ? ? ? ? ? ? ? "pd.mac,\n" +
? ? ? ? ? ? ? ? "pd.unique_code,\n" +
? ? ? ? ? ? ? ? "pd.type,\n" +
? ? ? ? ? ? ? ? "pd.system_version,\n" +
? ? ? ? ? ? ? ? "pdr.user_id,\n" +
? ? ? ? ? ? ? ? "pu.user_name,\n" +
? ? ? ? ? ? ? ? "pu.user_type\n" +
? ? ? ? ? ? ? ? "FROM\n" +
? ? ? ? ? ? ? ? "pos_user_device_relation pdr, pos_user pu, pos_device pd\n" +
? ? ? ? ? ? ? ? "WHERE pdr.device_id = pd.id AND pdr.user_id = pu.id AND pdr.user_id in (select id from pos_user where distributor_id=?1)",
? ? ? ? countQuery = "SELECT count(*) FROM\n" +
? ? ? ? ? ? ? ? "pos_user_device_relation pdr, pos_user pu, pos_device pd\n" +
? ? ? ? ? ? ? ? "WHERE pdr.device_id = pd.id AND pdr.user_id = pu.id AND pdr.user_id in (select id from pos_user where distributor_id=?1)",
? ? ? ? nativeQuery = true
)
Page<Object[]> findUserAndDeviceInfoByDistributorId2(Long distributorId, Pageable pageable);

可以看到這樣只能用Object[]來接收結(jié)果集,而不能直接將返回參數(shù)定義為PosUserDeviceRelationDto對(duì)象,否則會(huì)報(bào)no converter的異常。

那如何將Object[]的結(jié)果集轉(zhuǎn)換為PosUserDeviceRelationDto對(duì)象呢?

首先先看一下Object[]每個(gè)對(duì)象的類型:BigInteger BigInteger String String String String String BigInteger String Integer

這是可以發(fā)現(xiàn)雖然mysql數(shù)據(jù)庫(kù)定義的是bigint(20)類型,但是結(jié)果集是BigInteger,不能直接用Long接收,所以專門定義一個(gè)dto的構(gòu)造器如下:

public PosUserDeviceRelationDto(BigInteger posUserDeviceId,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BigInteger deviceId,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String deviceImei,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String deviceMac,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String deviceUniqueCode,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String deviceType,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String deviceSystemVersion,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BigInteger userId,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String username,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Integer userType) {
? ? this.posUserDeviceId = posUserDeviceId == null ? null : posUserDeviceId.longValue();
? ? this.deviceId = deviceId == null ? null : deviceId.longValue();
? ? this.deviceImei = deviceImei;
? ? this.deviceMac = deviceMac;
? ? this.deviceUniqueCode = deviceUniqueCode;
? ? this.deviceType = deviceType;
? ? this.deviceSystemVersion = deviceSystemVersion;
? ? this.userId = userId == null ? null : userId.longValue();
? ? this.username = username;
? ? // UserTypeConverter是繼承自javax.persistence.AttributeConverter的類型轉(zhuǎn)換器
? ? this.userType = new PosUserEntityConstants.UserTypeConverter().convertToEntityAttribute(userType);
}

然后直接調(diào)用構(gòu)造即可:

Page<Object[]> userAndDeviceInfoByDistributorId2 = posUserDeviceRelationRepository.findUserAndDeviceInfoByDistributorId2(1L, PageRequest.of(0, 10));
for (Object[] objects : userAndDeviceInfoByDistributorId2.getContent()) {
? ? // 轉(zhuǎn)換成dto的方法一:將objects中的所有參數(shù)強(qiáng)轉(zhuǎn)為對(duì)應(yīng)類型,傳遞到dto的構(gòu)造器中;dto對(duì)象定義好對(duì)應(yīng)的構(gòu)造器
? ? PosUserDeviceRelationDto dto1 = new PosUserDeviceRelationDto(
? ? ? ? ? ? (BigInteger) objects[0],
? ? ? ? ? ? (BigInteger) objects[1],
? ? ? ? ? ? (String ? ?) objects[2],
? ? ? ? ? ? (String ? ?) objects[3],
? ? ? ? ? ? (String ? ?) objects[4],
? ? ? ? ? ? (String ? ?) objects[5],
? ? ? ? ? ? (String ? ?) objects[6],
? ? ? ? ? ? (BigInteger) objects[7],
? ? ? ? ? ? (String ? ?) objects[8],
? ? ? ? ? ? (Integer ? ) objects[9]);
? ? System.out.println(dto1);

網(wǎng)上還能搜到另外一種解決方法,就是通過反射的方法簡(jiǎn)化dto的轉(zhuǎn)化步驟(http://m.fzitv.net/article/238470.htm),但是這個(gè)存在bug,如果返回的objects數(shù)組中有一個(gè)值為null,那么getClass()方法獲取類的類型就會(huì)報(bào)錯(cuò),所以改為將每個(gè)參數(shù)的類型直接傳入進(jìn)去,可以這樣使用反射其實(shí)省不了多少工夫了:

Page<Object[]> userAndDeviceInfoByDistributorId2 = posUserDeviceRelationRepository.findUserAndDeviceInfoByDistributorId2(1L, PageRequest.of(0, 10));
for (Object[] objects : userAndDeviceInfoByDistributorId2.getContent()) {
? ? // 轉(zhuǎn)換成dto的方法二:反射的方法直接調(diào)用構(gòu)造
? ? PosUserDeviceRelationDto dto2 = caseDto(objects, new Class[]{BigInteger.class,
? ? ? ? ? ? ? ? ? ? BigInteger.class,
? ? ? ? ? ? ? ? ? ? String.class,
? ? ? ? ? ? ? ? ? ? String.class,
? ? ? ? ? ? ? ? ? ? String.class,
? ? ? ? ? ? ? ? ? ? String.class,
? ? ? ? ? ? ? ? ? ? String.class,
? ? ? ? ? ? ? ? ? ? BigInteger.class,
? ? ? ? ? ? ? ? ? ? String.class,
? ? ? ? ? ? ? ? ? ? Integer.class},
? ? ? ? ? ? PosUserDeviceRelationDto.class);
? ? System.out.println(dto2);
}
/**
?* 網(wǎng)頁(yè)中直接使用objectArray中獲取每一個(gè)class,但是這樣有一個(gè)問題,就是如果獲取的objectArray中有一個(gè)空值的話,不能獲取到class,
?* 導(dǎo)致不能獲取到對(duì)象的構(gòu)造器
?* @param objectArray
?* @param objectClassArray
?* @param dtoClass
?* @param <T>
?* @return
?*/
private <T> T caseDto(Object[] objectArray, Class[] objectClassArray, Class<T> dtoClass) throws Exception {
? ? Constructor<T> constructor = dtoClass.getConstructor(objectClassArray);
? ? return constructor.newInstance(objectArray);
}

例子涉及的部分源代碼

Repository

@Query(
        value = "SELECT\n" +
                "new com.hengbao.ethiopiatelecomrecharge.dao.dto.PosUserDeviceRelationDto(\n" +
                "pdr.id,\n" +
                "pdr.deviceId,\n" +
                "pd.imei,\n" +
                "pd.mac,\n" +
                "pd.uniqueCode,\n" +
                "pd.type,\n" +
                "pd.systemVersion,\n" +
                "pdr.userId,\n" +
                "pu.userName,\n" +
                "pu.userType\n" +
                ") \n" +
                "FROM \n" +
                "PosUserDeviceRelationEntity pdr, PosUserEntity pu, PosDeviceEntity pd \n" +
                "WHERE pdr.deviceId = pd.id AND pdr.userId = pu.id AND pdr.userId in (select id from PosUserEntity where distributorId=?1)",
        countQuery = "SELECT count(*) FROM \n" +
                "PosUserDeviceRelationEntity pdr, PosUserEntity pu, PosDeviceEntity pd \n" +
                "WHERE pdr.deviceId = pd.id AND pdr.userId = pu.id AND pdr.userId in (select id from PosUserEntity where distributorId=?1)"
)
Page<PosUserDeviceRelationDto> findUserAndDeviceInfoByDistributorId(Long distributorId, Pageable pageable);
@Query(
        value = "SELECT\n" +
                "pdr.id,\n" +
                "pdr.device_id,\n" +
                "pd.imei,\n" +
                "pd.mac,\n" +
                "pd.unique_code,\n" +
                "pd.type,\n" +
                "pd.system_version,\n" +
                "pdr.user_id,\n" +
                "pu.user_name,\n" +
                "pu.user_type\n" +
                "FROM\n" +
                "pos_user_device_relation pdr, pos_user pu, pos_device pd\n" +
                "WHERE pdr.device_id = pd.id AND pdr.user_id = pu.id AND pdr.user_id in (select id from pos_user where distributor_id=?1)",
        countQuery = "SELECT count(*) FROM\n" +
                "pos_user_device_relation pdr, pos_user pu, pos_device pd\n" +
                "WHERE pdr.device_id = pd.id AND pdr.user_id = pu.id AND pdr.user_id in (select id from pos_user where distributor_id=?1)",
        nativeQuery = true
)
Page<Object[]> findUserAndDeviceInfoByDistributorId2(Long distributorId, Pageable pageable);

DTO類

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class PosUserDeviceRelationDto implements Serializable {
    /**
     * 版本號(hào)
     */
    private static final long serialVersionUID = 1L; 
    private Long posUserDeviceId; 
    private Long deviceId;
    private String deviceImei;
    private String deviceMac;
    private String deviceUniqueCode;
    private String deviceType;
    private String deviceSystemVersion; 
    private Long userId;
    private String username;
    private PosUserEntityConstants.UserType userType; 
    public PosUserDeviceRelationDto(BigInteger posUserDeviceId,
                                    BigInteger deviceId,
                                    String deviceImei,
                                    String deviceMac,
                                    String deviceUniqueCode,
                                    String deviceType,
                                    String deviceSystemVersion,
                                    BigInteger userId,
                                    String username,
                                    Integer userType) {
        this.posUserDeviceId = posUserDeviceId == null ? null : posUserDeviceId.longValue();
        this.deviceId = deviceId == null ? null : deviceId.longValue();
        this.deviceImei = deviceImei;
        this.deviceMac = deviceMac;
        this.deviceUniqueCode = deviceUniqueCode;
        this.deviceType = deviceType;
        this.deviceSystemVersion = deviceSystemVersion;
        this.userId = userId == null ? null : userId.longValue();
        this.username = username;
        // UserTypeConverter是繼承自javax.persistence.AttributeConverter的類型轉(zhuǎn)換器
        this.userType = new PosUserEntityConstants.UserTypeConverter().convertToEntityAttribute(userType);
    }
}

test測(cè)試類:

@Test
public void testFindUserAndDeviceInfoByDistributorId() throws Exception {
    System.out.println("-----------------hql query-----------------");
    Page<PosUserDeviceRelationDto> userAndDeviceInfoByDistributorId = posUserDeviceRelationRepository.findUserAndDeviceInfoByDistributorId(1L, PageRequest.of(0, 10)); 
    System.out.println("count=" + userAndDeviceInfoByDistributorId.getTotalElements());
    if(userAndDeviceInfoByDistributorId.getContent() != null) {
        for (PosUserDeviceRelationDto dto : userAndDeviceInfoByDistributorId.getContent()) {
            System.out.println(dto);
        }
    }
 
    System.out.println("-----------------native sql query-----------------");
    Page<Object[]> userAndDeviceInfoByDistributorId2 = posUserDeviceRelationRepository.findUserAndDeviceInfoByDistributorId2(1L, PageRequest.of(0, 10));
    System.out.println("count=" + userAndDeviceInfoByDistributorId2.getTotalElements());
    if(userAndDeviceInfoByDistributorId2.getContent() != null) {
        for (Object[] objects : userAndDeviceInfoByDistributorId2.getContent()) {
            for (Object obj : objects) {
                System.out.print(obj + "(" + (obj == null ? null : obj.getClass().getSimpleName()) + ") ");
            }
            System.out.println();  
        }
 
        // 轉(zhuǎn)換為dto 方法一
        System.out.println("-----轉(zhuǎn)換dto的第一種方法-----");
        for (Object[] objects : userAndDeviceInfoByDistributorId2.getContent()) {
            // 轉(zhuǎn)換成dto的方法一:將objects中的所有參數(shù)強(qiáng)轉(zhuǎn)為對(duì)應(yīng)類型,傳遞到dto的構(gòu)造器中;dto對(duì)象定義好對(duì)應(yīng)的構(gòu)造器
            PosUserDeviceRelationDto dto1 = new PosUserDeviceRelationDto(
                    (BigInteger) objects[0],
                    (BigInteger) objects[1],
                    (String    ) objects[2],
                    (String    ) objects[3],
                    (String    ) objects[4],
                    (String    ) objects[5],
                    (String    ) objects[6],
                    (BigInteger) objects[7],
                    (String    ) objects[8],
                    (Integer   ) objects[9]);
            System.out.println(dto1);
        }
 
        // 轉(zhuǎn)換為dto 方法二
        System.out.println("-----轉(zhuǎn)換dto的第二種方法-----");
        for (Object[] objects : userAndDeviceInfoByDistributorId2.getContent()) {
            // 轉(zhuǎn)換成dto的方法二:反射的方法直接調(diào)用構(gòu)造
            PosUserDeviceRelationDto dto2 = caseDto(objects, new Class[]{BigInteger.class,
                            BigInteger.class,
                            String.class,
                            String.class,
                            String.class,
                            String.class,
                            String.class,
                            BigInteger.class,
                            String.class,
                            Integer.class},
                    PosUserDeviceRelationDto.class);
            System.out.println(dto2);
        }
    }
}
 
/**
 * 網(wǎng)頁(yè)中直接使用objectArray中獲取每一個(gè)class,但是這樣有一個(gè)問題,就是如果獲取的objectArray中有一個(gè)空值的話,不能獲取到class,
 * 導(dǎo)致不能獲取到對(duì)象的構(gòu)造器
 * @param objectArray
 * @param objectClassArray
 * @param dtoClass
 * @param <T>
 * @return
 */
private <T> T caseDto(Object[] objectArray, Class[] objectClassArray, Class<T> dtoClass) throws Exception {
    Constructor<T> constructor = dtoClass.getConstructor(objectClassArray);
    return constructor.newInstance(objectArray);
}

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • JavaCV 拉流存儲(chǔ)到本地示例解析

    JavaCV 拉流存儲(chǔ)到本地示例解析

    這篇文章主要介紹了JavaCV 拉流存儲(chǔ)到本地示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • elasticsearch kibana簡(jiǎn)單查詢講解

    elasticsearch kibana簡(jiǎn)單查詢講解

    今天小編就為大家分享一篇關(guān)于elasticsearch kibana簡(jiǎn)單查詢講解,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-02-02
  • 基于Column注解的columnDefinition用法

    基于Column注解的columnDefinition用法

    這篇文章主要介紹了Column注解的columnDefinition用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • Mybatis Plus ActiveRecord模式的具體使用

    Mybatis Plus ActiveRecord模式的具體使用

    ActiveRecord 是一種設(shè)計(jì)模式,它是一種在軟件開發(fā)中用于管理關(guān)系數(shù)據(jù)庫(kù)的模式,本文主要介紹了Mybatis Plus ActiveRecord模式的具體使用,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-07-07
  • java中實(shí)現(xiàn)一個(gè)定時(shí)任務(wù)的方式

    java中實(shí)現(xiàn)一個(gè)定時(shí)任務(wù)的方式

    本文介紹了三種在Java中實(shí)現(xiàn)定時(shí)任務(wù)的方法,并推薦使用Spring Boot注解方式,介紹了如何使用`@Scheduled`注解結(jié)合Cron表達(dá)式來設(shè)置定時(shí)任務(wù),并提供了一個(gè)示例配置文件
    2025-03-03
  • 基于SpringBoot?使用?Flink?收發(fā)Kafka消息的示例詳解

    基于SpringBoot?使用?Flink?收發(fā)Kafka消息的示例詳解

    這篇文章主要介紹了基于SpringBoot?使用?Flink?收發(fā)Kafka消息,本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-01-01
  • Java之SpringBoot定時(shí)任務(wù)案例講解

    Java之SpringBoot定時(shí)任務(wù)案例講解

    這篇文章主要介紹了Java之SpringBoot定時(shí)任務(wù)案例講解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • 關(guān)于mybatis plus 中的查詢優(yōu)化問題

    關(guān)于mybatis plus 中的查詢優(yōu)化問題

    這篇文章主要介紹了關(guān)于mybatis plus 中的查詢優(yōu)化問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-01-01
  • SpringBoot前后端分離項(xiàng)目之打包、部署到服務(wù)器詳細(xì)圖文流程

    SpringBoot前后端分離項(xiàng)目之打包、部署到服務(wù)器詳細(xì)圖文流程

    作為后臺(tái)開發(fā),項(xiàng)目打包部署是經(jīng)常性的操作,下面這篇文章主要給大家介紹了關(guān)于SpringBoot前后端分離項(xiàng)目之打包、部署到服務(wù)器的相關(guān)資料,文中通過代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • Springboot通過aop實(shí)現(xiàn)事務(wù)控制過程解析

    Springboot通過aop實(shí)現(xiàn)事務(wù)控制過程解析

    這篇文章主要介紹了Springboot通過aop實(shí)現(xiàn)事務(wù)控制過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-03-03

最新評(píng)論

贞丰县| 克东县| 蒲江县| 沙洋县| 井冈山市| 衡南县| 错那县| 新宾| 扶绥县| 安多县| 车致| 安平县| 于都县| 临洮县| 吉安县| 泉州市| 余干县| 红原县| 高陵县| 孝义市| 无为县| 重庆市| 沾益县| 石首市| 铜川市| 汶川县| 清丰县| 湘潭市| 永兴县| 巨野县| 晋宁县| 五原县| 九龙县| 右玉县| 双桥区| 辽中县| 嵩明县| 运城市| 延吉市| 阳山县| 蕉岭县|