File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Read-only view entities" Watch "Read-only view entities" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read-only view entities
 
Similar Threads
Any optimization solution?
WAS help please
SEAM without ejb
Deciphering the instructions
how to set a ArrayLIst property of form from jsp