Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read-only view entities

 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an entity class based on a view, which is supposed to be read-only. I already made all column properties "insertable = false, updatable = false". I also removed all setters, as they don't make sense. Would it make sense to also declare all properties as final? I'd say so...

Karsten
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I'd be trying to make it as clear a possible to developers that this entity is not for changing. However, I'm not sure if this will work. The way most ORMs work is to instantiate an instance of a class, then set property values. If properties are final, this is not going to work.
 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just realized that having no setters on my read-only entity classes would violate against the JavaBean spec saying every bean needs a getter AND setter. Is there a problem with that?

BTW: with "view entities" I really mean a DB view, which is made to be read-only - at least in my case.

Karsten
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic