Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make an readonly @Entity level in JPA?

 
hariharan jayaprakash
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JPA entity class in which i will be performing only retrieval operation, so how to make read only @Entity level..? Is there any annotations available to achieve it?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hariharan jayaprakash wrote:how to make read only @Entity level..? Is there any annotations available to achieve it?

It seems there are no specific JPA annotations to achieve this. But some JPA providers have a custom annotation for this purpose (e.g. EclipseLink has the @ReadOnly annotation).

But if the @Entity is read-only, why not create an immutable class yourself and don't provide any set-methods?

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic