JPA 2.2: Using find method to retrieve data from mysqlDB - java

I´m using JPA 2.2(Openjpa) running on OpenLiberty and mysqlVer 15.1 Distrib 10.1.21-MariaDB.
I have an object call Account where I use the entityManager.find to retrieve a given record.
The record is indeed retrieved but only this column "status" returns null.
But when I do the manual select against the DB,the value is there.
My Entity class
Account
package br.com.rsm.model;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
//#XmlRootElement
#Entity
#Table(name = "tb_account")
#NamedQueries({
#NamedQuery(name="Account.findByEmail", query="SELECT a FROM Account a where a.email = :email"),
#NamedQuery(name="Account.findByCpf", query="SELECT a FROM Account a where a.cpf = :cpf"),
#NamedQuery(name="Account.findByUserId", query="SELECT a FROM Account a where a.userId = :userId")
})
public class Account implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String userId;
private String fullname;
private String email;
private String birthdate;
private String cpf;
private String rg;
private String address;
private String addressNumber;
private String complement;
private String cep;
private String state;
private int city;
private String phone;
private String mobile;
private String carrier;
#Column(name = "status")
private String status;
private long leftSide;
private long rightSide;
private Timestamp created;
private String parentId;
private String parentSide;
private String networkSide;
private Timestamp activated;
private double points;
private String nickname;
private String nis;
private String whatsapp;
private long bank;
private String accountType;
private String branchNumber;
private String branchDigit;
private String accountNumber;
private String accountDigit;
private String accountOwner;
private String cpfAccountOwner;
private String facebookID;
private double career;
private double pb;
private int certID;
private String automaticRenovation;
private String emailPagamento;
#Transient
private Account rightSideAccount;
#Transient
private Account leftSideAccount;
#Transient
private boolean searchableBySignedInUser;
#Transient
private long totalCandidatosAgente;
#Transient
private long totalAgentes;
#Transient
private long totalAgentesBracoEsq;
#Transient
private long totalAgentesBracoDir;
#Transient
private long totalAnjos;
#Transient
private boolean cfaCompleto;
//#Transient
#OneToMany(cascade={CascadeType.ALL}, fetch = FetchType.LAZY, orphanRemoval = true)
#JoinColumn(name = "owner" )
List<Ticket> tickets = new ArrayList<Ticket>();
#OneToMany(cascade={CascadeType.ALL}, fetch = FetchType.LAZY, orphanRemoval = true)
#OrderBy("created DESC")
#JoinColumn(name = "accountId" )
private List<Score> scores = new ArrayList<Score>();
#OneToMany(cascade={CascadeType.ALL}, fetch = FetchType.LAZY, orphanRemoval = true)
#OrderBy("activated DESC")
#JoinColumn(name = "idAccount" )
private List<ProductAccount> productsAccount = new ArrayList<ProductAccount>();
#OneToMany(cascade={CascadeType.ALL}, fetch = FetchType.LAZY, orphanRemoval = true)
#JoinColumn(name = "origin" )
private List<Trade> trades = new ArrayList<Trade>();
/**
* Construtor
*/
public Account() {}
public List<Trade> getTrades() {
return trades;
}
public void setTrades(List<Trade> trades) {
this.trades = trades;
}
public List<ProductAccount> getProductsAccount() {
return productsAccount;
}
public void setProductsAccount(List<ProductAccount> productsAccount) {
this.productsAccount = productsAccount;
}
public List<Score> getScores() {
return scores;
}
public void setScores(List<Score> scores) {
this.scores = scores;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
public String getRg() {
return rg;
}
public void setRg(String rg) {
this.rg = rg;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getAddressNumber() {
return addressNumber;
}
public void setAddressNumber(String addressNumber) {
this.addressNumber = addressNumber;
}
public String getComplement() {
return complement;
}
public void setComplement(String complement) {
this.complement = complement;
}
public String getCep() {
return cep;
}
public void setCep(String cep) {
this.cep = cep;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getCity() {
return city;
}
public void setCity(int city) {
this.city = city;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getCarrier() {
return carrier;
}
public void setCarrier(String carrier) {
this.carrier = carrier;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public long getLeftSide() {
return leftSide;
}
public void setLeftSide(long leftSide) {
this.leftSide = leftSide;
}
public long getRightSide() {
return rightSide;
}
public void setRightSide(long rightSide) {
this.rightSide = rightSide;
}
public Timestamp getCreated() {
return created;
}
public void setCreated(Timestamp created) {
this.created = created;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentSide() {
return parentSide;
}
public void setParentSide(String parentSide) {
this.parentSide = parentSide;
}
public String getNetworkSide() {
return networkSide;
}
public void setNetworkSide(String networkSide) {
this.networkSide = networkSide;
}
public List<Ticket> getTickets() {
return tickets;
}
public void setTickets(List<Ticket> tickets) {
this.tickets = tickets;
}
public Timestamp getActivated() {
return activated;
}
public void setActivated(Timestamp activated) {
this.activated = activated;
}
public double getPoints() {
return points;
}
public void setPoints(double points) {
this.points = points;
}
#Transient
public String getShortName() {
if(fullname==null){
return "";
}
if (nickname == null || nickname.isEmpty() ) {
nickname = fullname;
}
if(nickname != null || !nickname.isEmpty()){
String[] arrTmp = fullname.replace("\n", " ").split(" ");
String shortName = "";
if(arrTmp.length >= 2){
shortName = arrTmp[0] + " " + arrTmp[1] ;
}else if(arrTmp.length >= 1){
shortName = arrTmp[0];
}
//Passo o limitador de tamanho para ambas situações.
if(shortName!=null){
if(shortName.length() > 20){
shortName = fullname.substring(0, 19) + "...";
}
}
return shortName;
}
return "";
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getNis() {
return nis;
}
public void setNis(String nis) {
this.nis = nis;
}
public String getWhatsapp() {
return whatsapp;
}
public void setWhatsapp(String whatsapp) {
this.whatsapp = whatsapp;
}
public long getBank() {
return bank;
}
public void setBank(long bank) {
this.bank = bank;
}
public String getAccountType() {
return accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public String getBranchNumber() {
return branchNumber;
}
public void setBranchNumber(String branchNumber) {
this.branchNumber = branchNumber;
}
public String getBranchDigit() {
return branchDigit;
}
public void setBranchDigit(String branchDigit) {
this.branchDigit = branchDigit;
}
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public String getAccountDigit() {
return accountDigit;
}
public void setAccountDigit(String accountDigit) {
this.accountDigit = accountDigit;
}
public String getAccountOwner() {
return accountOwner;
}
public void setAccountOwner(String accountOwner) {
this.accountOwner = accountOwner;
}
public String getCpfAccountOwner() {
return cpfAccountOwner;
}
public void setCpfAccountOwner(String cpfAccountOwner) {
this.cpfAccountOwner = cpfAccountOwner;
}
public String getFacebookID() {
return facebookID;
}
public void setFacebookID(String facebookID) {
this.facebookID = facebookID;
}
public double getCareer() {
return career;
}
public void setCareer(double career) {
this.career = career;
}
public double getPb() {
return pb;
}
public void setPb(double pb) {
this.pb = pb;
}
public int getCertID() {
return certID;
}
public void setCertID(int certID) {
this.certID = certID;
}
public String getAutomaticRenovation() {
return automaticRenovation;
}
public void setAutomaticRenovation(String automaticRenovation) {
this.automaticRenovation = automaticRenovation;
}
public String getEmailPagamento() {
return emailPagamento;
}
public void setEmailPagamento(String emailPagamento) {
this.emailPagamento = emailPagamento;
}
public Account getRightSideAccount() {
return rightSideAccount;
}
public void setRightSideAccount(Account rightSideAccount) {
this.rightSideAccount = rightSideAccount;
}
public Account getLeftSideAccount() {
return leftSideAccount;
}
public void setLeftSideAccount(Account leftSideAccount) {
this.leftSideAccount = leftSideAccount;
}
public boolean isSearchableBySignedInUser() {
return searchableBySignedInUser;
}
public void setSearchableBySignedInUser(boolean searchableBySignedInUser) {
this.searchableBySignedInUser = searchableBySignedInUser;
}
public long getTotalCandidatosAgente() {
return totalCandidatosAgente;
}
public void setTotalCandidatosAgente(long totalCandidatosAgente) {
this.totalCandidatosAgente = totalCandidatosAgente;
}
public long getTotalAgentes() {
return totalAgentes;
}
public void setTotalAgentes(long totalAgentes) {
this.totalAgentes = totalAgentes;
}
public long getTotalAgentesBracoEsq() {
return totalAgentesBracoEsq;
}
public void setTotalAgentesBracoEsq(long totalAgentesBracoEsq) {
this.totalAgentesBracoEsq = totalAgentesBracoEsq;
}
public long getTotalAgentesBracoDir() {
return totalAgentesBracoDir;
}
public void setTotalAgentesBracoDir(long totalAgentesBracoDir) {
this.totalAgentesBracoDir = totalAgentesBracoDir;
}
public long getTotalAnjos() {
return totalAnjos;
}
public void setTotalAnjos(long totalAnjos) {
this.totalAnjos = totalAnjos;
}
public boolean isCfaCompleto() {
return cfaCompleto;
}
public void setCfaCompleto(boolean cfaCompleto) {
this.cfaCompleto = cfaCompleto;
}
/**
* Adiciona uma nova classe Score
* #param score Score
*/
public void addScore(Score score) {
getScores().add(score);
}
public void addProductAccount(ProductAccount productAccount) {
getProductsAccount().add(productAccount);
}
public void addTrade(Trade trade) {
getTrades().add(trade);
}
#Override
public String toString() {
return "Account [id=" + id + ", userId=" + userId + ", fullname=" + fullname + ", email=" + email
+ ", birthdate=" + birthdate + ", cpf=" + cpf + ", rg=" + rg + ", address=" + address
+ ", addressNumber=" + addressNumber + ", complement=" + complement + ", cep=" + cep + ", state="
+ state + ", city=" + city + ", phone=" + phone + ", mobile=" + mobile + ", carrier=" + carrier
+ ", status=" + status + ", leftSide=" + leftSide + ", rightSide=" + rightSide + ", created=" + created
+ ", parentId=" + parentId + ", parentSide=" + parentSide + ", networkSide=" + networkSide
+ ", activated=" + activated + ", points=" + points + ", nickname=" + nickname + ", nis=" + nis
+ ", whatsapp=" + whatsapp + ", bank=" + bank + ", accountType=" + accountType + ", branchNumber="
+ branchNumber + ", branchDigit=" + branchDigit + ", accountNumber=" + accountNumber + ", accountDigit="
+ accountDigit + ", accountOwner=" + accountOwner + ", cpfAccountOwner=" + cpfAccountOwner
+ ", facebookID=" + facebookID + ", career=" + career + ", pb=" + pb + ", certID=" + certID
+ ", automaticRenovation=" + automaticRenovation + ", emailPagamento=" + emailPagamento
+ ", rightSideAccount=" + rightSideAccount + ", leftSideAccount=" + leftSideAccount
+ ", searchableBySignedInUser=" + searchableBySignedInUser + ", totalCandidatosAgente="
+ totalCandidatosAgente + ", totalAgentes=" + totalAgentes + ", totalAgentesBracoEsq="
+ totalAgentesBracoEsq + ", totalAgentesBracoDir=" + totalAgentesBracoDir + ", totalAnjos=" + totalAnjos
+ ", cfaCompleto=" + cfaCompleto + ", tickets=" + tickets + ", scores=" + scores + ", productsAccount="
+ productsAccount + ", trades=" + trades + "]";
}
}
And this is my select result( snapshot table is to big )
[
id=2111,
userId=99YWK,
fullname=PatrickRibeiroBraz,
email=null,
birthdate=null,
cpf=null,
rg=null,
address=null,
addressNumber=null,
complement=null,
cep=null,
state=null,
city=0,
phone=null,
mobile=null,
carrier=null,
status=null,
leftSide=0,
rightSide=0,
created=2018-06-1212: 09: 29.0,
parentId=999I2,
parentSide=null,
networkSide=null,
activated=null,
points=0.0,
nickname=null,
nis=null,
whatsapp=null,
bank=0,
accountType=null,
branchNumber=null,
branchDigit=null,
accountNumber=null,
accountDigit=null,
accountOwner=null,
cpfAccountOwner=null,
facebookID=null,
career=0.0,
pb=0.0,
certID=0,
automaticRenovation=null,
emailPagamento=null,
rightSideAccount=null,
leftSideAccount=null,
searchableBySignedInUser=false,
totalCandidatosAgente=0,
totalAgentes=0,
totalAgentesBracoEsq=0,
totalAgentesBracoDir=0,
totalAnjos=0,
cfaCompleto=false,
tickets={
IndirectList: notinstantiated
},
scores={
IndirectList: notinstantiated
},
productsAccount={
IndirectList: notinstantiated
},
trades={
IndirectList: notinstantiated
}
]
ID fullname status
2111 Patrick Ribeiro Braz C
Has anyone went through this before?

Related

My List<Object> is not being passed correctly as object of my ModelAndView

In my Spring Controller I have:
List<User> Users = this.userService.UsersList();
mav = new ModelAndView("users");
mav.addObject("Users", Users);
When I iterate over Users I can see all the attributes values of every element of my list.
This is my .jsp code:
<c:forEach items="${Users}" var="usr">
${usr}
</c:forEach>
This is my users class:
#Entity
#Table(name="usuario")
public class User implements Serializable {
#Id
#Column(name="id")
#GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
#JoinColumn(name = "id_perfil")
#OneToOne(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
private Perfil perfil;
#Column(name="nombre")
private String nombre;
#Column(name="usuario")
private String usuario;
#Column(name="contrasenia")
private String contrasenia;
#Column(name="correo")
private String correo;
#Column(name="telefono")
private String telefono;
#Column(name="imagen_perfil")
private String imagen_perfil;
#Column(name="intento_fallido")
private int intento_fallido;
#Column(name="intranet_id")
private Integer intranet_id;
#Column(name="intranet_notaria")
private Integer intranet_notaria;
#Column(name="intranet_token_codigo")
private String intranet_token_codigo;
#Column(name="intranet_token_fecha")
#Temporal(TemporalType.TIMESTAMP)
private Date intranet_token_fecha;
#Column(name="tesoreria_token_codigo")
private String tesoreria_token_codigo;
#Column(name="tesoreria_token_fecha")
#Temporal(TemporalType.TIMESTAMP)
private Date tesoreria_token_fecha;
#Column(name="activo")
private int activo;
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public Perfil getPerfil() { return perfil; }
public void setPerfil(Perfil perfil) { this.perfil = perfil; }
public String getNombre() { return nombre; }
public void setNombre(String nombre) { this.nombre = nombre; }
public String getUsuario() { return usuario; }
public void setUsuario(String usuario) { this.usuario = usuario; }
public String getContrasenia() { return contrasenia; }
public void setContrasenia(String contrasenia) { this.contrasenia = contrasenia; }
public String getCorreo() { return correo; }
public void setCorreo(String correo) { this.correo = correo; }
public String getTelefono() { return telefono; }
public void setTelefono(String telefono) { this.telefono = telefono; }
public String getImagenPerfil() { return imagen_perfil; }
public void setImagenPerfil(String imagen_perfil) { this.imagen_perfil = imagen_perfil; }
public int getIntentoFallido() { return intento_fallido; }
public void setIntentoFallido(int intento_fallido) { this.intento_fallido = intento_fallido; }
public Integer getIntranetId() { return intranet_id; }
public void setIntranetId(Integer intranet_id) { this.intranet_id = intranet_id; }
public Integer getIntranetNotaria() { return intranet_notaria; }
public void setIntranetNotaria(Integer intranet_notaria) { this.intranet_notaria = intranet_notaria; }
public String getIntranetTokenCodigo() { return intranet_token_codigo; }
public void setIntranetTokenCodigo(String intranet_token_codigo) { this.intranet_token_codigo = intranet_token_codigo; }
public Date getIntranetTokenFecha() { return intranet_token_fecha; }
public void setIntranetTokenFecha(Date intranet_token_fecha) { this.intranet_token_fecha = intranet_token_fecha; }
public String getTesoreriaTokenCodigo() { return tesoreria_token_codigo; }
public void setTesoreriaTokenCodigo(String tesoreria_token_codigo) { this.tesoreria_token_codigo = tesoreria_token_codigo; }
public Date getTesoreriaTokenFecha() { return tesoreria_token_fecha; }
public void setTesoreriaTokenFecha(Date tesoreria_token_fecha) { this.tesoreria_token_fecha = tesoreria_token_fecha; }
public int getActivo() { return activo; }
public void setActivo(int activo) { this.activo = activo; }
#Override
public String toString() {
return "Id:" + id + ", " + "Perfil:" + perfil.getNombre() + ", " + "Id_Perfil:" + perfil.getId() + ", " + "Nombre:" + nombre + ", " + "Usuario:" + usuario + ", " + "Correo:" + correo + ", " + "Teléfono:" + telefono + ", " + "Image_Perfil:" + imagen_perfil + ", " + "Intranet_Id:" + intranet_id + ", " + "Intranet_Notaria:" + intranet_notaria + ", " + "Activo:" + activo;
}
}
The problem is that ${usr} is only displaying some of my attributes, but not all! I need to display all the attributes in my jsp.
Try using camelCase notation if you are not doing so. For example instead of ${usr.imagen_perfil} use ${usr.imagenPerfil}. I think it will be expecting to use the object getters getImagenPerfil().

what meaning this error "java.util.stream.ReferencePipeline$3 cannot be cast to org.springframework.data.domain.Page"

i want filter my task depend the work id
but when run my code i have this error
java.util.stream.ReferencePipeline$3 cannot be cast to org.springframework.data.domain.Page
how i can solve these
this is my component
my services here:
public Page<TaskDataDTO> findAll(String workOrderId,Pageable pageable) {
log.debug("Request to get all TaskData");
if(workOrderId!=null)
return (Page<TaskDataDTO>) taskDataRepository.findAll(pageable).stream().filter(x-> x.getWorkOrderId()==workOrderId).map(taskDataMapper::toDto);
else
return null;
}
and my Controller here :
#GetMapping("/task-data/{workOrderId}")
public ResponseEntity<List<TaskDataDTO>> getAllTaskData(#PathVariable String workOrderId,Pageable pageable) {
if(workOrderId!=null)
{
log.debug("REST request to get a page of TaskData");
Page<TaskDataDTO> page = taskDataService.findAll(workOrderId,pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
else {
return null;
}
}
the task entity :
package com.asc.skyalign.domain;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.io.Serializable;
/**
* A TaskData.
*/
#Document(collection = "task_data")
public class TaskData implements Serializable {
private static final long serialVersionUID = 1L;
#Id
private String id;
#Field("roll")
private String roll;
#Field("azimuth")
private String azimuth;
#Field("tilt")
private String tilt;
#Field("sector_location_lat")
private String sectorLocationLat;
#Field("amt_imei")
private String amtImei;
#Field("wakeu_up_interval")
private String wakeuUpInterval;
#Field("sector_id")
private String sectorID;
#Field("sector_location_long")
private String sectorLocationLong;
#Field("task_name")
private String taskName;
#Field("task_description")
private String taskDescription;
#Field("work_order_id")
private String workOrderId;
private WorkOrder workOrder;
public void setWorkOrder(WorkOrder workOrder) {
this.workOrder = workOrder;
}
public WorkOrder getWorkOrder() {
return workOrder;
}
// jhipster-needle-entity-add-field - JHipster will add fields here
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRoll() {
return roll;
}
public TaskData roll(String roll) {
this.roll = roll;
return this;
}
public void setRoll(String roll) {
this.roll = roll;
}
public String getAzimuth() {
return azimuth;
}
public TaskData azimuth(String azimuth) {
this.azimuth = azimuth;
return this;
}
public void setAzimuth(String azimuth) {
this.azimuth = azimuth;
}
public String getTilt() {
return tilt;
}
public TaskData tilt(String tilt) {
this.tilt = tilt;
return this;
}
public void setTilt(String tilt) {
this.tilt = tilt;
}
public String getSectorLocationLat() {
return sectorLocationLat;
}
public TaskData sectorLocationLat(String sectorLocationLat) {
this.sectorLocationLat = sectorLocationLat;
return this;
}
public void setSectorLocationLat(String sectorLocationLat) {
this.sectorLocationLat = sectorLocationLat;
}
public String getAmtImei() {
return amtImei;
}
public TaskData amtImei(String amtImei) {
this.amtImei = amtImei;
return this;
}
public void setAmtImei(String amtImei) {
this.amtImei = amtImei;
}
public String getWakeuUpInterval() {
return wakeuUpInterval;
}
public TaskData wakeuUpInterval(String wakeuUpInterval) {
this.wakeuUpInterval = wakeuUpInterval;
return this;
}
public void setWakeuUpInterval(String wakeuUpInterval) {
this.wakeuUpInterval = wakeuUpInterval;
}
public String getSectorID() {
return sectorID;
}
public TaskData sectorID(String sectorID) {
this.sectorID = sectorID;
return this;
}
public void setSectorID(String sectorID) {
this.sectorID = sectorID;
}
public String getSectorLocationLong() {
return sectorLocationLong;
}
public TaskData sectorLocationLong(String sectorLocationLong) {
this.sectorLocationLong = sectorLocationLong;
return this;
}
public void setSectorLocationLong(String sectorLocationLong) {
this.sectorLocationLong = sectorLocationLong;
}
public String getTaskName() {
return taskName;
}
public TaskData taskName(String taskName) {
this.taskName = taskName;
return this;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public String getTaskDescription() {
return taskDescription;
}
public TaskData taskDescription(String taskDescription) {
this.taskDescription = taskDescription;
return this;
}
public void setTaskDescription(String taskDescription) {
this.taskDescription = taskDescription;
}
public String getWorkOrderId() {
return workOrderId;
}
public TaskData workOrderId(String workOrderId) {
this.workOrderId = workOrderId;
return this;
}
public void setWorkOrderId(String workOrderId) {
this.workOrderId = workOrderId;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
#Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof TaskData)) {
return false;
}
return id != null && id.equals(((TaskData) o).id);
}
#Override
public int hashCode() {
return 31;
}
// prettier-ignore
#Override
public String toString() {
return "TaskData{" +
"id=" + getId() +
", roll='" + getRoll() + "'" +
", azimuth='" + getAzimuth() + "'" +
", tilt='" + getTilt() + "'" +
", sectorLocationLat='" + getSectorLocationLat() + "'" +
", amtImei='" + getAmtImei() + "'" +
", wakeuUpInterval='" + getWakeuUpInterval() + "'" +
", sectorID='" + getSectorID() + "'" +
", sectorLocationLong='" + getSectorLocationLong() + "'" +
", taskName='" + getTaskName() + "'" +
", taskDescription='" + getTaskDescription() + "'" +
", workOrderId='" + getWorkOrderId() + "'" +
"}";
}
}
and the TaskDto is here:
package com.asc.skyalign.service.dto;
import java.io.Serializable;
/**
* A DTO for the {#link com.asc.skyalign.domain.TaskData} entity.
*/
public class TaskDataDTO implements Serializable {
private String id;
private String roll;
private String azimuth;
private String tilt;
private String sectorLocationLat;
private String amtImei;
private String wakeuUpInterval;
private String sectorID;
private String sectorLocationLong;
private String taskName;
private String taskDescription;
private String workOrderId;
private WorkOrderDTO workOrderDTO;
public void setWorkOrderDTO(WorkOrderDTO workOrderDTO) {
this.workOrderDTO = workOrderDTO;
}
public WorkOrderDTO getWorkOrderDTO() {
return workOrderDTO;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRoll() {
return roll;
}
public void setRoll(String roll) {
this.roll = roll;
}
public String getAzimuth() {
return azimuth;
}
public void setAzimuth(String azimuth) {
this.azimuth = azimuth;
}
public String getTilt() {
return tilt;
}
public void setTilt(String tilt) {
this.tilt = tilt;
}
public String getSectorLocationLat() {
return sectorLocationLat;
}
public void setSectorLocationLat(String sectorLocationLat) {
this.sectorLocationLat = sectorLocationLat;
}
public String getAmtImei() {
return amtImei;
}
public void setAmtImei(String amtImei) {
this.amtImei = amtImei;
}
public String getWakeuUpInterval() {
return wakeuUpInterval;
}
public void setWakeuUpInterval(String wakeuUpInterval) {
this.wakeuUpInterval = wakeuUpInterval;
}
public String getSectorID() {
return sectorID;
}
public void setSectorID(String sectorID) {
this.sectorID = sectorID;
}
public String getSectorLocationLong() {
return sectorLocationLong;
}
public void setSectorLocationLong(String sectorLocationLong) {
this.sectorLocationLong = sectorLocationLong;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public String getTaskDescription() {
return taskDescription;
}
public void setTaskDescription(String taskDescription) {
this.taskDescription = taskDescription;
}
public String getWorkOrderId() {
return workOrderId;
}
public void setWorkOrderId(String workOrderId) {
this.workOrderId = workOrderId;
}
#Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof TaskDataDTO)) {
return false;
}
return id != null && id.equals(((TaskDataDTO) o).id);
}
#Override
public int hashCode() {
return 31;
}
// prettier-ignore
#Override
public String toString() {
return "TaskDataDTO{" +
"id=" + getId() +
", roll='" + getRoll() + "'" +
", azimuth='" + getAzimuth() + "'" +
", tilt='" + getTilt() + "'" +
", sectorLocationLat='" + getSectorLocationLat() + "'" +
", amtImei='" + getAmtImei() + "'" +
", wakeuUpInterval='" + getWakeuUpInterval() + "'" +
", sectorID='" + getSectorID() + "'" +
", sectorLocationLong='" + getSectorLocationLong() + "'" +
", taskName='" + getTaskName() + "'" +
", taskDescription='" + getTaskDescription() + "'" +
", workOrderId='" + getWorkOrderId() + "'" +
"}";
}
}
Thank you.
return (Page<TaskDataDTO>) taskDataRepository.findAll(pageable).stream().filter(x-> x.getWorkOrderId()==workOrderId).map(taskDataMapper::toDto);
The line above is missing a terminal operation to consume the stream. Try adding something like .collect(Collectors.toList())
Here's the package description for java.util.stream

Getting and putting Json into Pojo class

So I've made an app that should be able to search for an artist off the Spotify API. The response returns a 200 code. But the returned object is null. Meaning that either the response code should be 204 or that something is wrong with my class. The class is made with pojo and seems right.
I can't seem to figure out what is wrong.
Here are the code.
Artist Class
public class Artists {
#SerializedName("href")
#Expose
private String href;
#SerializedName("items")
#Expose
private List<Item> items;
#SerializedName("limit")
#Expose
private Integer limit;
#SerializedName("next")
#Expose
private String next;
#SerializedName("offset")
#Expose
private Integer offset;
#SerializedName("previous")
#Expose
private String previous;
#SerializedName("total")
#Expose
private Integer total;
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
public List<Item> getItems() {
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public String getNext() {
return next;
}
public void setNext(String next) {
this.next = next;
}
public Integer getOffset() {
return offset;
}
public void setOffset(Integer offset) {
this.offset = offset;
}
public Object getPrevious() {
return previous;
}
public void setPrevious(String previous) {
this.previous = previous;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
#Override
public String toString() {
return "Artists{" +
"href='" + href + '\'' +
", items=" + items +
", limit=" + limit +
", next='" + next + '\'' +
", offset=" + offset +
", previous='" + previous + '\'' +
", total=" + total +
'}';
}
Item Class
public class Item {
#SerializedName("external_urls")
#Expose
private ExternalUrls externalUrls;
#SerializedName("followers")
#Expose
private Followers followers;
#SerializedName("genres")
#Expose
private List<String> genres;
#SerializedName("href")
#Expose
private String href;
#SerializedName("id")
#Expose
private String id;
#SerializedName("images")
#Expose
private List<Image> images;
#SerializedName("name")
#Expose
private String name;
#SerializedName("popularity")
#Expose
private Integer popularity;
#SerializedName("type")
#Expose
private String type;
#SerializedName("uri")
#Expose
private String uri;
public ExternalUrls getExternalUrls() {
return externalUrls;
}
public void setExternalUrls(ExternalUrls externalUrls) {
this.externalUrls = externalUrls;
}
public Followers getFollowers() {
return followers;
}
public void setFollowers(Followers followers) {
this.followers = followers;
}
public List<String> getGenres() {
return genres;
}
public void setGenres(List<String> genres) {
this.genres = genres;
}
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<Image> getImages() {
return images;
}
public void setImages(List<Image> images) {
this.images = images;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getPopularity() {
return popularity;
}
public void setPopularity(Integer popularity) {
this.popularity = popularity;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUri() {
return uri;
}
#Override
public String toString() {
return "Item{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", type='" + type + '\'' +
'}';
}
MainActivity
public void searchForArtist(View view) {
String q = "Justin Bieber";
TrackService trackService = ApiUtils.getTrackService();
Call<Artists> artistSearch = trackService.SearchForArtist("Bearer " + AuthToken, Accept, contentType, q, type, market, limit, offset);
Log.d("TEST", artistSearch.request().url().toString());
Log.d("TEST", " " + artistSearch.request().headers());
Log.d("Tokens", AuthToken);
Log.d("Tokens", " " + RefreshToken);
artistSearch.enqueue(new Callback<Artists>() {
#Override
public void onResponse(Call<Artists> call, Response<Artists> response) {
if (response.isSuccessful()) {
if (response.body().getItems() != null) {
Item artists = response.body().getItems().get(0);
artistID = artists.getId();
Toast.makeText(MainActivity.this, "Yeehaw", Toast.LENGTH_LONG).show();
searchForTracks(artistID);
} else {
Toast.makeText(MainActivity.this, "No content in Items", Toast.LENGTH_LONG).show();
Log.d("BODY",response.body().toString());
}
} else {
String message = "Problem " + response.code() + " " + response.body();
Log.d("Tracks", message);
Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(Call<Artists> call, Throwable t) {
Toast.makeText(MainActivity.this, "REEEEEEEE", Toast.LENGTH_LONG).show();
}
});
}

Limit Results from One to Many Relationship

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.sanu.siri.entity;
import javax.persistence.*;
import java.sql.Blob;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* #author Sanu AK
*/
#Entity
#Table(name = "Parts")
public class Parts implements SuperEntity {
#Id
#GeneratedValue(strategy = GenerationType.TABLE, generator = "map")
#TableGenerator(name = "map", table = "Id_Gen", pkColumnName = "Tables_Names", valueColumnName = "Gen_keys", pkColumnValue = "PartsDTO", initialValue = 1, allocationSize = 1)
private int id;
private String partName;
private String partNumber;
private String barCode;
private String brand;
private String partType;
private String country;
private String vehicleModel;
private String packSize;
private String location;
private String rackNo;
private String roq;
private String rql;
#Column(name = "imageUrl1")
private String imageUrl1;
#Column(name = "imageUrl2")
private String imageUrl2;
#Column(name = "imageUrl3")
private String imageUrl3;
#Column(name = "imageUrl4")
private String imageUrl4;
private Blob image;
private Blob image1;
private Blob image2;
private Blob image3;
private String warranty;
private Date adedDate;
#Enumerated(value = EnumType.STRING)
private Catogary catogary;
#ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
#JoinTable(name = "Parts_FuelType",
joinColumns = {#JoinColumn(name = "part_ID", referencedColumnName = "id")},
inverseJoinColumns = {#JoinColumn(name = "fuel_Type", referencedColumnName = "id")})
private List<FuelType> fuelTypes = new ArrayList<>();
#OneToMany(mappedBy = "parts", cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
private List<OrderDetails> orderDetail = new ArrayList<>();
#OneToMany(mappedBy = "parts", cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
#OrderBy("date DESC")
private List<Bulk> bulks = new ArrayList<>();
public Parts() {
}
public Parts(String partName, String partNumber, String barCode, String brand, String partType, String country, String vehicleModel, String packSize, String location, String rackNo, String roq, String rql, Blob image, Blob image1, Blob image2, Blob image3, String warranty, Date adedDate, Catogary catogary, List<FuelType> fuelTypes, List<OrderDetails> orderDetail, List<Bulk> bulks) {
this.partName = partName;
this.partNumber = partNumber;
this.barCode = barCode;
this.brand = brand;
this.partType = partType;
this.country = country;
this.vehicleModel = vehicleModel;
this.packSize = packSize;
this.location = location;
this.rackNo = rackNo;
this.roq = roq;
this.rql = rql;
this.image = image;
this.image1 = image1;
this.image2 = image2;
this.image3 = image3;
this.warranty = warranty;
this.adedDate = adedDate;
this.catogary = catogary;
this.fuelTypes = fuelTypes;
this.orderDetail = orderDetail;
this.bulks = bulks;
}
public Parts(int id, String partName, String partNumber, String barCode, String brand, String partType, String country, String vehicleModel, String packSize, String location, String rackNo, String roq, String rql, String imageUrl1, String imageUrl2, String imageUrl3, String imageUrl4, Blob image, Blob image1, Blob image2, Blob image3, String warranty, Date adedDate, Catogary catogary, List<FuelType> fuelTypes, List<OrderDetails> orderDetail, List<Bulk> bulks) {
this.setId(id);
this.partName = partName;
this.partNumber = partNumber;
this.barCode = barCode;
this.brand = brand;
this.partType = partType;
this.country = country;
this.vehicleModel = vehicleModel;
this.packSize = packSize;
this.location = location;
this.rackNo = rackNo;
this.roq = roq;
this.rql = rql;
this.imageUrl1 = imageUrl1;
this.imageUrl2 = imageUrl2;
this.imageUrl3 = imageUrl3;
this.imageUrl4 = imageUrl4;
this.image = image;
this.image1 = image1;
this.image2 = image2;
this.image3 = image3;
this.warranty = warranty;
this.adedDate = adedDate;
this.catogary = catogary;
this.fuelTypes = fuelTypes;
this.orderDetail = orderDetail;
this.bulks = bulks;
}
public String getImageUrl1() {
return imageUrl1;
}
public void setImageUrl1(String imageUrl1) {
this.imageUrl1 = imageUrl1;
}
public String getImageUrl2() {
return imageUrl2;
}
public void setImageUrl2(String imageUrl2) {
this.imageUrl2 = imageUrl2;
}
public String getImageUrl3() {
return imageUrl3;
}
public void setImageUrl3(String imageUrl3) {
this.imageUrl3 = imageUrl3;
}
public String getImageUrl4() {
return imageUrl4;
}
public void setImageUrl4(String imageUrl4) {
this.imageUrl4 = imageUrl4;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPartName() {
return partName;
}
public void setPartName(String partName) {
this.partName = partName;
}
public String getPartNumber() {
return partNumber;
}
public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getPartType() {
return partType;
}
public void setPartType(String partType) {
this.partType = partType;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getVehicleModel() {
return vehicleModel;
}
public void setVehicleModel(String vehicleModel) {
this.vehicleModel = vehicleModel;
}
public String getPackSize() {
return packSize;
}
public void setPackSize(String packSize) {
this.packSize = packSize;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getRackNo() {
return rackNo;
}
public void setRackNo(String rackNo) {
this.rackNo = rackNo;
}
public String getRoq() {
return roq;
}
public void setRoq(String roq) {
this.roq = roq;
}
public String getRql() {
return rql;
}
public void setRql(String rql) {
this.rql = rql;
}
public Blob getImage() {
return image;
}
public void setImage(Blob image) {
this.image = image;
}
public Blob getImage1() {
return image1;
}
public void setImage1(Blob image1) {
this.image1 = image1;
}
public Blob getImage2() {
return image2;
}
public void setImage2(Blob image2) {
this.image2 = image2;
}
public Blob getImage3() {
return image3;
}
public void setImage3(Blob image3) {
this.image3 = image3;
}
public String getWarranty() {
return warranty;
}
public void setWarranty(String warranty) {
this.warranty = warranty;
}
public Date getAdedDate() {
return adedDate;
}
public void setAdedDate(Date adedDate) {
this.adedDate = adedDate;
}
public Catogary getCatogary() {
return catogary;
}
public void setCatogary(Catogary catogary) {
this.catogary = catogary;
}
public List<FuelType> getFuelTypes() {
return fuelTypes;
}
public void setFuelTypes(List<FuelType> fuelTypes) {
this.fuelTypes = fuelTypes;
}
public List<OrderDetails> getOrderDetail() {
return orderDetail;
}
public void setOrderDetail(List<OrderDetails> orderDetail) {
this.orderDetail = orderDetail;
}
public List<Bulk> getBulks() {
return bulks;
}
public void setBulks(List<Bulk> bulks) {
this.bulks = bulks;
}
#Override
public String toString() {
return "Parts{" +
"id=" + id +
", partName='" + partName + '\'' +
", partNumber='" + partNumber + '\'' +
", barCode='" + barCode + '\'' +
", brand='" + brand + '\'' +
", partType='" + partType + '\'' +
", country='" + country + '\'' +
", vehicleModel='" + vehicleModel + '\'' +
", packSize='" + packSize + '\'' +
", location='" + location + '\'' +
", rackNo='" + rackNo + '\'' +
", roq='" + roq + '\'' +
", rql='" + rql + '\'' +
", image=" + image +
", image1=" + image1 +
", image2=" + image2 +
", image3=" + image3 +
", warranty='" + warranty + '\'' +
", adedDate=" + adedDate +
", catogary=" + catogary +
", fuelTypes=" + fuelTypes +
", orderDetail=" + orderDetail +
", bulks=" + bulks +
'}';
}
}
I have a problem about this row. Is there any way to limit those BulkList when we call this BulkList from Part.
#OrderBy("date DESC")
private List<Bulk> bulks = new ArrayList<>();
I mean like this
This is My Repo
public interface PartsRepo extends CrudRepository<Parts, Integer> {
Parts findPartsByBarCode(String barCode) throws Exception;
List<Parts> findPartsByPartNameContaining(String partName) throws Exception;
List<Parts> findPartsByPartNumberContaining(String partNumber) throws Exception;
Parts findPartsByPartNumber(String partNumber) throws Exception;
}
This is my Controller
#GetMapping(value = "/search")
public void searchParts(HttpServletRequest req) {
try {
return
Parts
p=partsService.searchParts(Integer.parseInt(req.getParameter("id")));
List<Bulk> bulkList=p.getBulks();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
I want to limit the bulkList results from the entity.. is there any way to do that..?
List<Bulk> bulkList=p.getBulks();
limit above list from the
#OrderBy("date DESC")
private List<Bulk> bulks = new ArrayList<>();
review
I have a problem about this row is there any way to limit those BulkList when we call this BulkList from Part.
I want to limit the bulkList results from the entity. Is there any way to do that?
#OneToMany(mappedBy = "bulk", cascade=CascadeType.PERSIST, fetch=LAZY)
#BatchSize(size=5)
private List<Bulk> bulks = new ArrayList<>();
You can do this way

Not able to save child table data using hibernate

I am Developing Web service, in this there is scenario of parent child tables as below
**Parent Table**
#Entity
#Table(name = "INSTITUTE_LIST_MST")
#JsonIgnoreProperties(ignoreUnknown = true)
public class InstituteInfoMatster
{
#Id
#Column(name = "LIST_ID")
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer listId;
#Column(name = "LIST_DESC")
private String description;
#Column(name = "LIST_VALUE")
private String value;
#Column(name = "URL")
private String url;
#Column(name = "LOGO", unique = false, length = 100000)
private byte[] logo;
#OneToMany(fetch = FetchType.EAGER, mappedBy = "instituteInfotMaster", cascade = CascadeType.ALL)
private List<InstituteInfoDetails> instituteInfoDetails = new ArrayList<InstituteInfoDetails>();
#Column(name = "CREATED_DT")
#Temporal(TemporalType.TIMESTAMP)
private Date createdDate = new Date();
#Column(name = "CREATED_BY")
private String createdBy;
#Column(name = "UPDATED_DT")
#Temporal(TemporalType.TIMESTAMP)
private Date updatedDate;
#Column(name = "UPDATED_BY")
private String updatedBy;
#Column(name = "RECORD_STATUS")
private String recordStatus = "A";
public Integer getListId()
{
return listId;
}
public void setListId(Integer listId)
{
this.listId = listId;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
public Date getCreatedDate()
{
return createdDate;
}
public void setCreatedDate(Date createdDate)
{
this.createdDate = createdDate;
}
public String getCreatedBy()
{
return createdBy;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public Date getUpdatedDate()
{
return updatedDate;
}
public void setUpdatedDate()
{
this.updatedDate = new Date();
}
public String getUpdatedBy()
{
return updatedBy;
}
public void setUpdatedBy(String updatedBy)
{
this.updatedBy = updatedBy;
}
public String getRecordStatus()
{
return recordStatus;
}
public void setActiveRecordStatus()
{
this.recordStatus = "A";
}
public void deleteRecord()
{
this.recordStatus = "D";
}
public List<InstituteInfoDetails> getInstituteInfoDetails()
{
return instituteInfoDetails;
}
public void setInstituteInfoDetails(List<InstituteInfoDetails> instituteInfoDetails)
{
this.instituteInfoDetails = instituteInfoDetails;
}
public byte[] getLogo()
{
return logo;
}
public void setLogo(byte[] logo)
{
this.logo = logo;
}
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
#Override
public String toString()
{
return "InstituteInfoMatster [listId=" + listId + ", description=" + description + ", value=" + value + ", url="
+ url + ", logo=" + Arrays.toString(logo) + ", instituteInfoDetails=" + instituteInfoDetails
+ ", createdDate=" + createdDate + ", createdBy=" + createdBy + ", updatedDate=" + updatedDate
+ ", updatedBy=" + updatedBy + ", recordStatus=" + recordStatus + "]";
}
}
Child Table
#Entity
#Table(name = "INSTITUTE_LIST_DETAILS")
public class InstituteInfoDetails
{
#Id
#Column(name = "LIST_DTL_ID")
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer listDtlId;
#ManyToOne
#JoinColumn(name = "LIST_ID", nullable = false)
#JsonProperty("instituteInfotMaster")
#JsonBackReference
private InstituteInfoMatster instituteInfotMaster;
#Column(name = "LIST_DTL_VALUE")
private String value;
#Column(name = "LIST_DTL_DESC", length = 5000)
private String description;
#Column(name = "STRING1", length = 5000)
private String string1;
#Column(name = "STRING2", length = 5000)
private String string2;
#Column(name = "STRING3", length = 5000)
private String string3;
#Column(name = "SEQUENCE_NO")
private int sequenceNo;
#Column(name = "NUMBER1")
private Double number1;
#Column(name = "NUMBER2")
private Double number2;
#Column(name = "NUMBER3")
private Double number3;
#Column(name = "DOCUMENT", unique = false, length = 100000)
private byte[] document;
#Column(name = "DOCUMENT_TYPE", length = 1)
private Integer documentType;
#Column(name = "DOCUMENT1", unique = false, length = 100000)
private byte[] document1;
#Column(name = "DOCUMENT1_TYPE", length = 1)
private Integer document1Type;
#Column(name = "DOCUMENT2", unique = false, length = 100000)
private byte[] document2;
#Column(name = "DOCUMENT2_TYPE", length = 1)
private Integer document2Type;
#Column(name = "CREATED_DT")
#Temporal(TemporalType.TIMESTAMP)
private Date createdDate = new Date();
#Column(name = "CREATED_BY")
private String createdBy;
#Column(name = "UPDATED_DT")
#Temporal(TemporalType.TIMESTAMP)
private Date updatedDate;
#Column(name = "UPDATED_BY")
private String updatedBy;
#Column(name = "RECORD_STATUS")
private String recordStatus = "A";
public Integer getListDtlId()
{
return listDtlId;
}
public void setListDtlId(Integer listDtlId)
{
this.listDtlId = listDtlId;
}
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public InstituteInfoMatster getComListMaster()
{
return instituteInfotMaster;
}
public void setComListMaster(InstituteInfoMatster instituteInfotMaster)
{
this.instituteInfotMaster = instituteInfotMaster;
}
public Date getCreatedDate()
{
return createdDate;
}
public void setCreatedDate()
{
this.createdDate = new Date();
}
public String getCreatedBy()
{
return createdBy;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public Date getUpdatedDate()
{
return updatedDate;
}
public void setUpdatedDate(Date updatedDate)
{
this.updatedDate = updatedDate;
}
public String getUpdatedBy()
{
return updatedBy;
}
public void setUpdatedBy(String updatedBy)
{
this.updatedBy = updatedBy;
}
public String getRecordStatus()
{
return recordStatus;
}
public void setRecordStatus(String recordStatus)
{
this.recordStatus = recordStatus;
}
public InstituteInfoMatster getInstituteInfotMaster()
{
return instituteInfotMaster;
}
public void setInstituteInfotMaster(InstituteInfoMatster instituteInfotMaster)
{
this.instituteInfotMaster = instituteInfotMaster;
}
public String getString1()
{
return string1;
}
public void setString1(String string1)
{
this.string1 = string1;
}
public String getString2()
{
return string2;
}
public void setString2(String string2)
{
this.string2 = string2;
}
public String getString3()
{
return string3;
}
public void setString3(String string3)
{
this.string3 = string3;
}
public int getSequenceNo()
{
return sequenceNo;
}
public void setSequenceNo(int sequenceNo)
{
this.sequenceNo = sequenceNo;
}
public Double getNumber1()
{
return number1;
}
public void setNumber1(Double number1)
{
this.number1 = number1;
}
public Double getNumber2()
{
return number2;
}
public void setNumber2(Double number2)
{
this.number2 = number2;
}
public Double getNumber3()
{
return number3;
}
public void setNumber3(Double number3)
{
this.number3 = number3;
}
public byte[] getDocument()
{
return document;
}
public void setDocument(byte[] document)
{
this.document = document;
}
public Integer getDocumentType()
{
return documentType;
}
public void setDocumentType(Integer documentType)
{
this.documentType = documentType;
}
public byte[] getDocument1()
{
return document1;
}
public void setDocument1(byte[] document1)
{
this.document1 = document1;
}
public Integer getDocument1Type()
{
return document1Type;
}
public void setDocument1Type(Integer document1Type)
{
this.document1Type = document1Type;
}
public byte[] getDocument2()
{
return document2;
}
public void setDocument2(byte[] document2)
{
this.document2 = document2;
}
public Integer getDocument2Type()
{
return document2Type;
}
public void setDocument2Type(Integer document2Type)
{
this.document2Type = document2Type;
}
#Override
public String toString()
{
return "InstituteInfoDetails [listDtlId=" + listDtlId + ", instituteInfotMaster=" + instituteInfotMaster
+ ", value=" + value + ", description=" + description + ", string1=" + string1 + ", string2=" + string2
+ ", string3=" + string3 + ", sequenceNo=" + sequenceNo + ", number1=" + number1 + ", number2="
+ number2 + ", number3=" + number3 + ", document=" + Arrays.toString(document) + ", documentType="
+ documentType + ", document1=" + Arrays.toString(document1) + ", document1Type=" + document1Type
+ ", document2=" + Arrays.toString(document2) + ", document2Type=" + document2Type + ", createdDate="
+ createdDate + ", createdBy=" + createdBy + ", updatedDate=" + updatedDate + ", updatedBy=" + updatedBy
+ ", recordStatus=" + recordStatus + "]";
}
}
now i am using below rest service request to add master data with child
{"description":"Placements","value":"Placements","url":"/Placements","instituteInfoDetails":[{"value":"Test"}]}
Code to save data
#Override
public void addInstituteInfoMaster(com.zertones.model.common.InstituteInfoMatster instituteInfoMatster)
{
Session session = sessionFactory.getCurrentSession();
session.saveOrUpdate(instituteInfoMatster);
}
but while saving it gives me below error
org.hibernate.PropertyValueException: not-null property references a null or transient value : com.zertones.model.common.InstituteInfoDetails.instituteInfotMaster
I searched and did as per solutions i added the cascade type information, but it did not helped.
create bidirectional Setter method for set InstituteInfoMatster to instituteInfoDetails
change class InstituteInfoMatster
public void setInstituteInfoDetails(List<InstituteInfoDetails> instituteInfoDetails)
{
for(InstituteInfoDetails ins : instituteInfoDetails){
ins.setComListMaster(this);
}
this.instituteInfoDetails = instituteInfoDetails;
}
I think you have a typo in this code:
#ManyToOne
#JoinColumn(name = "LIST_ID", nullable = false)
#JsonProperty("instituteInfotMaster")
#JsonBackReference
private InstituteInfoMatster instituteInfotMaster;
Shouldn't it be instituteInfoMaster instead?
EDIT: or maybe not, I can se you have multiple typos there, such as InstituteInfoMatster etc. Still, I think it would worth to fix these typos while you still can (if you still can, of course).

Categories

Resources