Search code examples
javajpajakarta-eejpa-2.1

JPA property access isMethod


JPA property access: getter and setter. Does it support isMethod for boolean? For example,

@Entity
@Access(AccessType.PROPERTY)   
public class Foo {
   private boolean closed;


   public boolean isClosed() {
       return this.closed;
   }

}

Could not find relevant info in JPA spec 2.1.


Solution

  • Yes. It does.

    From JSR 338: JavaTM Persistence API, Version 2.1

    2.2 Persistent Fields and Properties

    ...for every persistent property property of type T of the entity, there is a getter method, getProperty, and setter method setProperty. For boolean properties, isProperty may be used as an alternative name for the getter method.