Jhipster,Pom配置,延迟加载实体…正在加载所有内容

问题描述 投票:1回答:1

我有这个模型:您可以将其粘贴到此处https://start.jhipster.tech/jdl-studio/

entity NmsDomain {
  name String required,
  logo ImageBlob,
  brandImg ImageBlob
}


entity NmsTenant {
  name String required,
  image ImageBlob
}


entity NmsZone {
  name String required,
  description String,
  active Boolean,
  lastModifiedDate ZonedDateTime,
  lastModifiedBy String 
}

entity NmsEmployee {
  extensionNumber String,
  photo ImageBlob
}


entity NmsEmployeeLog {
  begin ZonedDateTime,
  end ZonedDateTime,
  deviceType String,
  make String, 
  model String, 
  imei String, 
  serialNumber String, 
  ipAddress String, 
  macAddress String, 
  wifiNetwork String
}

relationship OneToOne {
  NmsEmployee{user(firstName)} to User
  }


  relationship ManyToMany {
  NmsEmployee{possibleZones(name)} to NmsZone{employeePossible}, 
  NmsEmployee{activeZones(name)} to NmsZone{employeeActive}, 
  NmsEmployee{possibleTenants(name)} to NmsTenant{employeePossible}, 
  NmsDomain{user(firstName)} to User{NmsDomain}
}


relationship ManyToOne {
  NmsEmployeeLog{employee} to NmsEmployee, 
  NmsEmployeeLog{zone(name)} to NmsZone, 
  NmsEmployee{domain(name)} to NmsDomain,
  NmsEmployee{tenant(name)} to NmsTenant, 
 NmsTenant{domain(name)} to NmsDomain, 
  NmsZone{tenant(name)} to NmsTenant
}

而且当我在EmployeeLog存储库中进行操作时:

@Query(value ="SELECT entity FROM NmsEmployeeLog entity WHERE entity.employee.id = :empId",
countQuery ="select count(entity) FROM NmsEmployeeLog entity WHERE entity.employee.id = :empId")

Page<NmsEmployeeLog> findByEmpId(@Param("empId") Long empId, Pageable pageable);

在EmployeeLog.java中,我有:

    @ManyToOne(fetch = FetchType.LAZY) 
    @JsonIgnoreProperties("nmsEmployeeLogs")
    private NmsEmployee employee;

    @ManyToOne
    @JsonIgnoreProperties("nmsEmployeeLogs")
    private NmsZone zone;

但是我仍然将所有员工,用户,域,租户信息与很多图像相关联。太慢了...对于员工日志中只有1行,我得到:

[
  {
    "id": 6,
    "begin": "2019-02-03T07:54:00Z",
    "end": "2019-02-03T07:54:00Z",
    "deviceType": null,
    "make": null,
    "model": null,
    "imei": null,
    "serialNumber": null,
    "ipAddress": null,
    "macAddress": null,
    "wifiNetwork": null,
    "employee": {
      "id": 11,
      "extensionNumber": "1223",
      "photo": "iVBORw0KGgoAAAANSUhEUg ….LOTS OF IMAGE CODE.”,
      "photoContentType": "image/png",

      "user": {
        "id": 3,
        "login": "admin",
        "firstName": "Admin",
        "lastName": "IGomes",
        "email": “m…”,
        "activated": true,
        "langKey": "pt-pt",
        "imageUrl": "",
        "resetDate": null
      },
      "domain": {
        "id": 2,
        "name": "Fe ",
        "logo": "/9j/4 ….LOTS OF IMAGE CODE”,
        "brandImgContentType": "image/jpeg",
        "brandLink": null

      },
      "tenant": {
        "id": 4,
        "name": "Heathlands V",
        "image": “LOTS OF IMAGE CODE…..”,
        "imageContentType": "image/jpeg",
        "domain": {
          "id": 2,
          "name": "Feds ",
          "logo": "/9j/4A== ….”,
          "logoContentType": "image/jpeg",
          "brandImg": "/9j/4AAQSkAAH//Z …..LOTS OF IMAGE CODE”,
          "brandImgContentType": "image/jpeg"

        }
      },
      "possibleZones": null,
      "activeZones": null,
      "possibleTenants": null
    },
    "zone": {
      "id": 27,
      "name": "EHBlk EH1",
      "description": "EH Block 1",
      "active": true,
      "lastModifiedDate": "2019-09-28T11:39:32Z",
      "lastModifiedBy": "Louis ",
      "tenant": {
        "id": 4,
        "name": "Heathlands V",
        "image": "/9j/4AAQSkZJRgABAQAAA …. LOTS OF IMAGE CODE”,
        "imageContentType": "image/jpeg",
        "domain": {
          "id": 2,
          "name": "Fed ",
          "logo":  LOTS OF IMAGE CODE….”,
          "brandImgContentType": "image/jpeg",
        }
      }
    }
  },
  {
Next Row Log ...

不仅仅是这些字段:

public interface EmployeeLog {
     Long getId();
     ZonedDateTime getBegin();
     ZonedDateTime getEnd();
     String getDevice();
     String getType();
     String getMake();
     String getModel();
     String getImei();
     String getSerialNumber();
     String getIpAddress();
     String getMacAddress();
     String getWifiNetwork();
}

如果我创建一个界面并仅选择这些字段。有用:我什么也没有得到。

但是我需要对大多数实体执行此操作...

是否有一种方法可以指示实体中的延迟加载?

hibernate spring-boot jpa lazy-loading jhipster
1个回答
0
投票

我将此添加到pom.xml并进行./mvn clean compile(我想我已经忘记了)

© www.soinside.com 2019 - 2024. All rights reserved.