Relative Content

Tag Archive for javaspringhibernatespring-data-jpa

understanding behaviour of spring data repository findAllByAAndB method

I have two tables, tableA and tableB. The columns in tableA are a, b, and c, while the columns in tableB are a, d, and e. Here, a is the primary key of tableA and a foreign key in tableB. Additionally, d is the primary key of tableB, and there is a one-to-one mapping between tableA and tableB.

Hibernate Parent Child Mapping in Spring Boot Project

`Hello. I want to save the data I took from the Account Code Template table to the Account Code table. The data in these tables has a parent-child relationship (child can also be in the parent. I will add an example visual for your understanding). How can I follow a method to save the data I receive from the Account Code Template to the Account Code table? I share my entity classes.

JPA column updatable=false

i have a simple POJO (field1, field2, field3), i use Hibernate for ORM, and i have a basic need :
i should never update the field3 in DB. once a row is inserted the first time, when i call a repo to fetch an object by id (findById), even if i call the setter for field3 (setField3()), the call to save method should throw an error or an exception specifying that i am trying to update field3 and i should not.
i don’t know if hibernate can handle this need or if i have to implement custom method to do that.
PS : i tried this @Column(name = "field3", updatable = false) and when i fetch and set another value for field3, the call to save succeeds and updates my entity.