aspose file tools*
The moose likes Object Relational Mapping and the fly likes Entity Class Must Not be final ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Entity Class Must Not be final ?" Watch "Entity Class Must Not be final ?" New topic
Author

Entity Class Must Not be final ?

Uppala Ramana
Greenhorn

Joined: Jan 14, 2010
Posts: 14
Why is that the entity class must not be final ?


Ramana Uppala
SCJA,SCJP
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

What does declaring a class final prevent? If you know the answer to this, you should be able to deduce the answer to the question.
Uppala Ramana
Greenhorn

Joined: Jan 14, 2010
Posts: 14
"The Entity Class Must Not Be Final".This statement is in EJB3.0 specification.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Problem solved then?
Uppala Ramana
Greenhorn

Joined: Jan 14, 2010
Posts: 14
Paul,

I want to know the reason behind the statement "The Entity Class Must Not Be Final".

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

That's what I thought. That's why I asked you to do a little bit of thinking yourself. So... what does it mean to make a class final? What effect does it have on the class?

Clearly that effect prevents the ORM software from working correctly, and that's why it's prohibited.
Uppala Ramana
Greenhorn

Joined: Jan 14, 2010
Posts: 14
That's what I thought. That's why I asked you to do a little bit of thinking yourself. So... what does it mean to make a class final? What effect does it have on the class?

Clearly that effect prevents the ORM software from working correctly, and that's why it's prohibited


Paul,

So, what the ORM software will do by creating a sub class of each Entity Bean ?
Is it will add some thing to each Entity ?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Uppala Ramana wrote:So, what the ORM software will do by creating a sub class of each Entity Bean ?
Is it will add some thing to each Entity ?


Yes, I would assume that's what it will do too.

(You may notice that we have now answered two questions in this thread simply on the basis of looking at the description of how something works, without actually knowing anything at all about the real details of how it works. We might be wrong, but in real life it doesn't matter, since all we have to do is to remember not to make the entity classes final and we can go on our way designing and implementing systems.)
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Paul Clapham wrote:
We might be wrong, but in real life it doesn't matter


I've built my entire career around that particular sentiment.
 
Don't get me started about those stupid light bulbs.
 
subject: Entity Class Must Not be final ?