0

I'm currently working on a Spring Boot backend application with JPA and I encountered a peculiar error. After setting up the columns in the entity file, we have a public function that returns a boolean based on whether something is active or not.

    public boolean isPartnerActive() {
        return this.status.getPartnerStatus().contentEquals("A");
    }

This function is only meant to be used as boolean values in our controller, but when we try running our backend application to test a "Post" call in the Partner controller, we encounter a NullPointerError saying we have null field called partneractive. During our debugging, we changed the function name to isActive and the same error occurred, but the null field this time is active.

It seems as though this is notation issue with is as the starting letters for a function, because as soon as we changed the function name or added the @JsonIgnore annotation to the function, we were able to make the post call.

I'm not necessarily looking for a solution to this issue; I just want to understand why this situation happens.

Bosies
  • 23
  • 4

1 Answers1

0

Annotate the isPartnerActive() method in your entity as @Transient and the exception will go away.

How it works, follow this link

Adil Khalil
  • 2,073
  • 3
  • 21
  • 33