-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping a strategy pattern
PostPosted: Fri Nov 21, 2008 9:33 pm 
Newbie

Joined: Fri Nov 21, 2008 8:56 pm
Posts: 15
I have a class with some properties, where one of them is a strategy. The strategy doesn't have any fields, so I don't want to have a table for strategies. I'd love to map the strategy in the same table that maps every other property of my class (theoretically, Hibernate only needs the class type to be able to retrieve my object). How can I do something like that?

I ilustrate the case (if you show me how to map this with annotations I'll really apreciate it, but I will settle with any mapping you know):

Code:
public class SomeClass {
    private String name;
    private MyStrategy strategy;
    ...
}

public Interface MyStrategy {
    public void doYourThing();
}

public class OneStrategy implements MyStrategy {
    public void doYourThing() {
        ...
    }
}

public class AnotherStrategy implements MyStrategy {
    public void doYourThing() {
        ...
    }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.