admin管理员组文章数量:1123359
Good afternoon, I am currently building a microservice that executes the call of an SP (Stored Procedure) in Quarkus using EntityManager and StoredProcedureQuery, the issue is that I am experiencing problems when mapping what the DB returns, there are differences (there are records that are being returned duplicated because they have the same primary key, however, the rest of the data changes) in terms of what the SP returns when executing it manually with what is returned when mapping to the list in Java, so I would like to know how I can debug from IntellijIdea what the DB returns and know why the data is being duplicated, or if you can give me ideas as to why it could be duplicated.
I add the main classes that I am using
Entity
package com.tmve.account.beans;
import lombok.Getter;
import lombok.ToString;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(
name = PostpaidAccount.NAME_QUERY_BUSCAR_CUENTAS_ROLES_X_DOC_IDE,
procedureName = "PERS.PKG_COMP_CUENTAS.BUSCAR_CUENTAS_ROLES_X_DOC_ID",
resultClasses = {PostpaidAccount.class},
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, type = String.class),
@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class),
@StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class),
})
})
@Getter
@Entity
@ToString
public class PostpaidAccount implements Serializable {
public static final String NAME_QUERY_BUSCAR_CUENTAS_ROLES_X_DOC_IDE= "BuscarCuentasRolesxDocId";
private static final long serialVersionUID = 1L;
@Id
@Column(name = "V_NUMERO_CUENTA")
Long account;
@Column(name = "V_NUM_CTA_PAGADORA")
Long billingAccountNumber;
@Column(name = "V_NUM_CTA_DIG_VERI")
Long billingAccountNumberValidators;
@Column(name = "V_TIPO_CUENTA")
String accountType;
@Column(name = "V_ESTADO")
String accountStatus;
@Column(name = "V_NOMBRE_ESTADO")
String accountStatusDescription;
@Column(name = "V_ID_PRODUCTO")
Integer productoId;
@Column(name = "NOMBRE_PRODUCTO")
String productName;
@Column(name = "FECHA_INICIO_PROD")
Date customerSince;
@Column(name = "NOMBRES")
String accountHolder;
@Column(name = "V_TIPO_RELACION")
String relationshipType;
@Column(name = "V_PLATAF")
int platformId;
@Column(name = "V_IDENTIFICADOR")
String identifier;
@Column(name = "NOMBRE_AREA")
String marketName;
}
Repoository
In this class I would like to know what I can implement or how I can debug what the DB returns once the following line is executed:
storedProcedureQuery.execute();
package com.tmve.account.repositoty.impl;
import com.tmve.account.beans.PostpaidAccount;
import com.tmve.account.repositoty.IFindPostpaidAccountByDocumentRepository;
import lombok.extern.slf4j.Slf4j;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.persistence.EntityManager;
import javax.persistence.StoredProcedureQuery;
import java.util.List;
@Slf4j
@Singleton
public class FindPostpaidAccountByDocumentRepository implements IFindPostpaidAccountByDocumentRepository {
@Inject
EntityManager entityManager;
@Override
public List<PostpaidAccount> getPostpaidAccount(String documentType, String documentNumber) {
StoredProcedureQuery storedProcedureQuery=entityManager
.createNamedStoredProcedureQuery("BuscarCuentasRolesxDocId");
storedProcedureQuery.setParameter(1,documentNumber);
storedProcedureQuery.setParameter(2,Integer.parseInt(documentType));
storedProcedureQuery.execute();
List<PostpaidAccount> result= storedProcedureQuery.getResultList();
return result;
}
}
This is how logs are displayed when debugging in IntelliJ Idea:
And according to what the DB returns, the records should look like this:
As we can see, the records are being duplicated and I don't understand why. Could it have something to do with the approach of using the EntityManager?
本文标签: javaHow to debug a SP response in Quarkus using EntityManagerStack Overflow
版权声明:本文标题:java - How to debug a SP response in Quarkus using EntityManager - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736566215a1944707.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论