Please don't double post to this list. If you haven't received a reply, it's likely because no one knows the answer. I do try to answer all the e-mails this list receives that I know the answer too. Sometimes it takes me 3-4 weeks, but usually other users step up and answer by then. Sorry we don't know the answer, but if you discover what it is - please let us know.
Matt On 7/10/07, Leo Barrientos C <[EMAIL PROTECTED]> wrote:
Hello, does anybody know how to implement the State Pattern with JPA using only em.find and @tags? I need to get a Object with a concrete state object only doing em.find , The entity table has a id name and id_state fields; so if the id_state is 0 i need the ConcreteStateA loaded in actualState and if 1 ConcreteStateB in actualState. I've been reading a lot, but no answers founded ..... helpme. My entity is: public class Cuenta implements Serializable { private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("BancoUnidadDePersistencia"); @Id @Column(name = "id", nullable = false) private Integer id; @Column(name = "id_cliente", nullable = false) private int idCliente; @Column(name = "fecha_apertura", nullable = false) @Temporal(TemporalType.TIMESTAMP) private Date fechaApertura; @Column(name = "id_estado", nullable = false) private int idEstado; @Transient private AccountState actualState; @Transient private float saldo; /** Creates a new instance of Cuenta */ public Cuenta() { } .......................................... public void execute(){ this.actualState.execute(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- http://raibledesigns.com