Весенняя загрузка страницы с EntityGraph
Я создаю свою сущность с помощью EntityGraph:
@Entity(name = "protocolo")
@TypeDefs({@TypeDef(name = "JsonObjetoProtocoloUserType", typeClass = JsonObjetoProtocoloUserType.class),
@TypeDef(name = "JsonServicoCalculadoUserType", typeClass = JsonServicoCalculadoUserType.class)})
@SuppressWarnings("serial")
@NamedEntityGraphs({
@NamedEntityGraph( name = "Protocolo.grid", attributeNodes = {
@NamedAttributeNode(value = "tipo"),
@NamedAttributeNode(value = "natureza"),
@NamedAttributeNode(value = "cliente"),
@NamedAttributeNode(value = "subNatureza"),
@NamedAttributeNode(value = "statusProtocolo", subgraph = "FetchManagers.Subgraph.Status")
},
subgraphs = {
@NamedSubgraph(name = "FetchManagers.Subgraph.Status", type = StatusProtocolo.class, attributeNodes = {@NamedAttributeNode(value = "status")}),
@NamedSubgraph(name = "FetchManagers.Subgraph.Status", type = StatusProtocolo.class, attributeNodes = {@NamedAttributeNode(value = "usuario")})
}),
@NamedEntityGraph( name = "Protocolo.tudo", attributeNodes = {
@NamedAttributeNode(value = "tipo"),
@NamedAttributeNode(value = "natureza"),
@NamedAttributeNode(value = "cartorioParceiro"),
@NamedAttributeNode(value = "formaEntrega"),
@NamedAttributeNode(value = "partesProtocolo"),
@NamedAttributeNode(value = "intimacaosProtocolo"),
@NamedAttributeNode(value = "checklist"),
@NamedAttributeNode(value = "objetos"),
@NamedAttributeNode(value = "cliente"),
@NamedAttributeNode(value = "subNatureza"),
@NamedAttributeNode(value = "statusProtocolo", subgraph = "FetchManagers.Subgraph.Status")
},
subgraphs = {
@NamedSubgraph(name = "FetchManagers.Subgraph.Status", type = StatusProtocolo.class, attributeNodes = {@NamedAttributeNode(value = "status")}),
@NamedSubgraph(name = "FetchManagers.Subgraph.Status", type = StatusProtocolo.class, attributeNodes = {@NamedAttributeNode(value = "usuario")})
})
})
public class Protocolo extends AbstractEntity{
protected static Logger logger= LoggerFactory.getLogger(Protocolo.class);
Long numero;
@Column(name = "tipo_protocolo_id")
@Convert(converter = TipoProtocoloConverter.class)
@NotNull
private TipoProtocolo tipo;
@OneToOne
@NotNull
private Natureza natureza;
@OneToOne
private CartorioParceiro cartorioParceiro;
@OneToOne
private SubNatureza subNatureza;
@OneToOne(fetch = FetchType.LAZY)
@NotNull
private FormaEntrega formaEntrega;
@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
@JoinColumn(name="protocolo_id")
@JsonIgnore
Set<ParteProtocolo> partesProtocolo;
@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
@JoinColumn(name="protocolo_id")
@NotNull
private Set<StatusProtocolo> statusProtocolo;
@JsonIgnore
@Type(type = "JsonServicoCalculadoUserType")
List<ServicoCalculado> servicos;
@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
@JoinColumn(name="protocolo_id")
@JsonIgnore
Set<IntimacaoProtocolo> intimacaosProtocolo;
private Integer vias = 0;
@Column
@Type(type = "org.jadira.usertype.moneyandcurrency.joda.PersistentMoneyAmount",
parameters = {@org.hibernate.annotations.Parameter(name = "currencyCode", value = "BRL")})
@JsonIgnore
private Money valor;
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDate data_doc;
@NotEmpty
private String parte;
@NotEmpty
@CpfCnpj
private String parteDocumento;
@Column(name = "data_protocolo")
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime dataProtocolo = LocalDateTime.now();
@Column(name = "dt_protocolo_informado_portal")
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime dataProtocoloInformadoPortal;
@Column(name = "dt_registro_informado_portal")
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime dataRegistroInformadoPortal;
@Column(name = "dt_certidao_informado_portal")
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime dataCertidaoInformadoPortal;
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDate data_prevista;
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDate data_vencimento;
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime data_entrega;
@Column(name = "pasta_pj")
private String pastaPJ;
private String responsavel;
@NotEmpty
private String apresentante;
private String apresentante_rg;
private String telefone;
@Email
private String email;
@Column(length=10485760)
private String observacoes;
@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
@JoinColumn(name="protocolo_id")
@JsonIgnore
private Set<ChecklistProtocolo> checklist;
@Type(type = "JsonObjetoProtocoloUserType")
@JsonIgnore
private List<ObjetoProtocoloVO> objetos;
@Column( name = "registro_referencia")
private String registroReferencia;
@Column( name = "numero_registro_referencia")
private Long numeroRegistroReferencia;
@Column( name = "numero_registro")
private String numeroRegistro;
@Column( name = "observacao_registro", length=10485760)
private String observacaoRegistro;
@Column( name = "situacao_atual_registro",length=10485760)
private String situacaoAtualRegistro;
@Column(name = "dt_registro")
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime dtRegistro;
@Column(name = "dt_devolvido")
@JsonFormat(pattern = "dd/MM/yyyy")
private LocalDateTime dtDevolvido;
@Column Long nrExameCalculoReferencia;
@Column(length=10485760, name = "texto_carimbo")
@JsonIgnore
private String textoCarimbo;
@Column(length=10485760, name = "texto_certidao")
@JsonIgnore
private String textoCertidao;
@JsonIgnore
@OneToOne
private Cliente cliente;
@Column(name = "ic_guarda_conservacao")
private Boolean icGuardaConservacao = false;
@Column(name = "ic_possui_sigilo_legal")
private Boolean icPossuiSigiloLegal = false;
@Column(name = "pedido_id")
private Long pedido;
...
}
но теперь мне нужно разбить свой результат на страницы, и когда я запускаю метод в своем репозитории, использующий один @EntityGraph, разбиение на страницы не работает (я регистрирую hibernate sql, и когда я удаляю @EntityGraph, показываются лимит и смещение в журнале, если Я поставил @EntityGraph предел и смещение не появляются)
это мой код для запуска sql:
Не работает
@Override
@EntityGraph(value = "Protocolo.grid", type = EntityGraph.EntityGraphType.FETCH)
Page<Protocolo> findAll( Pageable pageable);
Работа
@Override
Page<Protocolo> findAll( Pageable pageable);