1

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!

4
  • Did'nt quite get you?What do you really want to achieve Commented Feb 16, 2017 at 8:45
  • @Akshay I would like to store a property to database but never being retrieve it by the app. Commented Feb 16, 2017 at 8:46
  • Ok..It can be easily achieved.Just make a PoJo class map it and never call it.Just store it..as in just keep setting and never call get..Hope you got it Commented Feb 16, 2017 at 8:48
  • @Akshay Thanks, I'm just being stupid today. I've just implemented it. lazy fetch type + no getter Commented Feb 16, 2017 at 9:02

2 Answers 2

1

Add only setters but never getters for that specific property. Also considering the object serialization to xml or json pay attention in excluding that specific field from being serialized.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes + lazy fetching
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.