0

I am not able to see the values of the object in debug and it show InvocationException.

enter image description here

enter image description here

enter image description here

This is the code snippet by which I am trying to get the data from DB as previousObject by repository.getById(passing the Key from the mappedObject) which is mapped to the FundRequest Entity Class.

final FundRequest mappedObject = requestToEntityMapper.map(requests, entityClass.FundRequest);

final JpaRepository<U, Object> repository = repositoryStrategyProvider.getRepository(repoType);

Storable previousObject = null;

try {
     ----> previousObject = repository.getById(mappedObject.getKey()); <-----
}
catch (Exception e) {
    System.out.println("error: " + e);
}

FundRequest Class is as below. Is it something to do with the Lombok & Hibernate annotations?

I am using @Data, @Entity. Now according to this article : Here I tried Removing @Data annotation and tried with @Getter @Setter, but still it throws the same exception

package com.abhishekpandey.jsonWriterReader.domain;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Entity;
import org.springframework.util.StringUtils;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name="FUND_REQUEST", schema="MYFUNDDB")
public class FundRequest implements Storable {
    
    @Id
    @Column(name = "DESC_CD")
    private String descriptorCode;

    @Column(name = "AREA_CD")
    private String areaCode = "A";

    @Column(name= "ACCT_CD")
    private String accountingCode = StringUtils.EMPTY;

    @Column(name = "FUND_CD")
    private String fundCode = StringUtils.EMPTY;

    @Column(name = "LOAD_STAT_C")
    private Short loadStatusCode = 1;

    @Column(name = "USER_I")
    private String userId;

    @Column(name = "MOD_TS")
    public Timestamp lastUpdated;

    @Column(name = "CREATION_TS")
    public Timestamp createdAt;

    @Override
    public String getKey() {
        return String.valueOf(descriptorCode);
    }
}
Abb
  • 3,051
  • 3
  • 17
  • 34
  • Please add a bit more detail, simply with a POJO, its difficult to comment on the cause of the exception – Saurabh Jhunjhunwala Mar 30 '22 at 19:49
  • Looks like issue with `final JpaRepository repository = repositoryStrategyProvider.getRepository(repoType);`. Please check the class of this. Is it returning you the correct object. – Saurabh Jhunjhunwala Mar 30 '22 at 20:05
  • @SaurabhJhunjhunwala Yes it returns me the FundRequest repo object. I have added the variables info. It gets the values, but doesn't show them. – Abb Mar 30 '22 at 20:07
  • Please check the class, may be a mapping / conversion is going for a toss – Saurabh Jhunjhunwala Mar 30 '22 at 20:08
  • @SaurabhJhunjhunwala Here mappedObject & previousObject are of same Class Objects. The data coming from DB is getting mapped only in the FundRequest.class. When I hover over mappedObjects it shows the values but not for the previousObject – Abb Mar 30 '22 at 20:21
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/243463/discussion-between-abb-and-saurabh-jhunjhunwala). – Abb Mar 30 '22 at 20:26

0 Answers0