Hello,
I would like to support different databases in my app.
Today I created an example app where I defined following simple classes:
A public interface
public interface Customer { public int getId(); public void setId(int id); public String getName(); public void setName(String name); }
public class CustomerVO implements Customer,Serializable { private int id; private String name; public int getId() { return this.id; } public void setId(int id) { this.id = id; } ... }
@Entity @Table(name="test_cust2") public class CustomerMySQL implements Customer,Serializable { private int id; private String name; @Column(name="id") @Id(generate=GeneratorType.AUTO) public int getId() { return this.id; } public void setId(int id) { this.id = id; } }
@Stateless public class CustomerDAOBean implements CustomerDAO { private @PersistenceContext(unitName="test") EntityManager em; public Customer persistCustomer(Customer cust) { em.persist(cust); return cust; } }
You should pay more attention to the error message - Customer is an interface, not an entity bean.