Hello, does anybody know how to implement the State Pattern with JPA
ussing 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 reading a lot, but no answers found..... 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, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".