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]