| Author |
Read-only view entities
|
Karsten Wutzke
Ranch Hand
Joined: Jul 20, 2010
Posts: 106
|
|
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
|
OCJP JavaSE 6 (86%)
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
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.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Karsten Wutzke
Ranch Hand
Joined: Jul 20, 2010
Posts: 106
|
|
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
|
 |
 |
|
|
subject: Read-only view entities
|
|
|