-->
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: Is there a way to change the DiscriminatorColumn Value
PostPosted: Wed Sep 01, 2010 6:08 pm 
Newbie

Joined: Wed Feb 01, 2006 10:45 am
Posts: 18
Location: Salzburg, Austria
hi,

i have a fairly complex domain object with lots of methods. after analyzing it a bit i discovered that i could create multiple extended object types with a (almost) disjunct set of methods that would only be determined by the current state (4 states).

I want to transform this Domain object into the following:
Code:
@Entity
public class Domain() {
    private enum State state;

    public void method1();
    public void method2();
    public void method3();
}


transformed:
Code:
@Entity @DiscriminatorColumn("state")
public abstract class Domain() {}

@Entity @DiscriminatorValue("state1")
public State1 extends Domain() {
    public void method1() {
        state = "state2";
    }
}

@Entity @DiscriminatorValue("state2")
public State2 extends Domain() {
    public void method2() {}
}

@Entity @DiscriminatorValue("state1")
public State3 extends Domain() {
    public void method3() {}
}


So if i change the state of the Domain Object "State1" i could then query for State2.class and have only the appropriate methods available. The user could not invoke the method method1() anymore as it is not relevant anymore. as a benefit the state checks within the current implementation of the methods would disappear (eg. you can't invoke method3() if you are not in state="state3")

is there any way to achieve this? I fact I'm trying to implement a kind of intelligent Memento pattern with Hibernate. My tests with the latest Version 3.5.5 did not succeed.

thanks in advance

_________________
greetings,
kris


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.