ORM framework that extends base class with database-implementation.
Posted
by aioobe
on Stack Overflow
See other posts from Stack Overflow
or by aioobe
Published on 2010-05-25T06:39:17Z
Indexed on
2010/05/25
6:41 UTC
Read the original article
Hit count: 295
I have a game consisting of a client / server + a webpage. A central notion in both client and game-/webserver is an Account
. Accounts are stored in a database thus I'm in need of some ORM and recently had a look at Hibernate and Cayenne.
My understanding however, is that both frameworks provide an "DatabaseBackedAccount"
-class which I extend with my other Account
methods. My problem is that the Account
class is reused heavily on the client side, and I would obviously not want to include database-related code on the client implementation.
My current solution is to have an Account
class (shared by server and client) and extend this with a DatabaseBackedAccount
(overriding setter-methods and providing a commit method) on the server side. I find this quite natural and nice, however I've had to implement all gory sql-details and ORM myself.
Is there any way to "turn the table" in any existing ORM framework, so that the generated classes extend my existing class?
© Stack Overflow or respective owner