DEV Community

Java doubts

Using a Java Record

While studying for a project that is starting, I came across the situation of using the Record or a class using JPA.

Behaviors

I just realized that the Record does not behave in the same way as a class using Lombok, because it creates the attributes as Final. Today I am trying to mature the scenario in using it.

1- It is not allowing me to insert the value of the encrypted password because it starts the object and it cannot be changed. When I start the object with the password already encrypted, I have a problem because it does not have the ID.

2- I tried to choose to encrypt the password when creating the user, but when JPA executes the save method, I still have an ID problem because it does not provide the ID. Since it was supposed to be incremented automatically.

Previous projects

All the projects I participated in, they always had an ORM structure, with JPA|Hibernate.
I always tried to maintain the structure because I understood that it was easy to read and well structured. But I have always worked with the normal class and building with the lombook features and configurations for creating the database.

Current studies

Now I am trying to adjust the knowledge of the Record structure, to understand, if the problem is my understanding or the Record that will always behave this way.

Top comments (0)