Search code examples
hibernatejpaormpersistencehibernate-mapping

Create save-only property in JPA/Hibernate


I'm adding a property to existing DTO. The property is intended to be used only from the database. It means it will be stored only. There will be no usages of it across our application. It is needed for our Product Owner to make reports. I would like to make it store-only i.e. to be stored but never retrieved from the database. Is there such an opportunity in JPA/Hibernate? Thanks for any help!


Solution

  • Actually, the answer was too easy. I ended up with not adding getter for the property and specifying @Basic(fetch = FetchType.LAZY) on the property.

    UPDATE: It works only with getter.