spring-petclinic-microservices icon indicating copy to clipboard operation
spring-petclinic-microservices copied to clipboard

Consider removing Lombok

Open arey opened this issue 1 year ago • 4 comments

Now that the application is based on Java 17, we could consider removing Lombok and using the Record instead.

arey avatar Dec 28 '23 16:12 arey

Can I take this task?

shobhakamath avatar Dec 29 '23 07:12 shobhakamath

Yes, sure @shobhakamath I'm not sure removing Lombok without adding boilerplate code is possible anywhere. But you could try by submitting small pull request

arey avatar Dec 29 '23 10:12 arey

I'm afraid it won't be possible to use records for Jpa @ Entity'ies. My concern is https://vladmihalcea.com/java-records-jpa-hibernate/

Can Java Records be used as JPA or Hibernate entities? One very common question is if Java records are going to simplify the way we are building JPA or Hibernate entities. And, the answer is no. They will not.

According to the JPA specification, an entity must follow these requirements:

the entity class needs to be non-final, the entity class needs to have a no-arg constructor that is either public or protected, the entity attributes must be non-final. However, as explained by this article, the Java Record type is defined like this:

the associated Java class is final, there is only one constructor that takes all attributes, the Java record attributes are final. So, according to the JPA specifications, a Java Record cannot be used as an entity.

bastiat avatar Dec 29 '23 11:12 bastiat

You're right @bastiat For JPA entities we could not use record but we could generate getters/setters with IDE In this repository, Lombok is also used by DTO, Service and Controller

arey avatar Dec 29 '23 16:12 arey