This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Read-only view entities Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Read-only view entities" Watch "Read-only view entities" New topic

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...


OCJP JavaSE 6 (86%)
Paul Sturrock

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.

subject: Read-only view entities
Similar Threads
SEAM without ejb
Any optimization solution?
WAS help please
Deciphering the instructions
how to set a ArrayLIst property of form from jsp