Managing Strategy objects with Hibernate & Spring
Posted
by Francois
on Stack Overflow
See other posts from Stack Overflow
or by Francois
Published on 2010-05-28T15:50:41Z
Indexed on
2010/05/28
15:51 UTC
Read the original article
Hit count: 314
This is a design question better explained with a Stack Overflow analogy:
Users can earn Badges. Users, Badges and Earned Badges are stored in the database. A Badge’s logic is run by a Badge Condition Strategy. I would prefer not to have to store Badge Condition Strategies in the database, because they are complex tree structure objects.
How do I associate a Badge stored in the database with its Badge Condition Strategy? I can only think of workaround solutions. For example: create 1 class per badge and use a SINGLE_TABLE inheritance strategy. Or get the badge from the database, and then programmatically lookup and inject the correct Badge Condition Strategy.
Thanks for suggesting a better design.
© Stack Overflow or respective owner