I think I have a similar question. We are evaluating Hibernate as a possible replacement of EJB CMP. One of the advantages that we have found with Entity Beans is that in our data model, we have several tables that contain nearly identical columns. We are able to have a single Entity Bean class gernerically represent those tables, and we simply deploy multiple EJBs with that bean class for each appropriate table. Ie, the same class represents different tables. Is there a way with Hibernate to create similar mappings? Such that we have a single class:
public class MyEntity {
private Long m_id;
public Long getId() { return m_id; }
public void setId(Long n) { m_id = n; }
private String m_name;
public String getName() { return m_name; }
public void setName(String n) { m_name = n; }
}
that maps to BOTH of these tables:
CREATE TABLE TABLE_A (
ID NUMBER NOT NULL,
NAME VARCHAR2(128) NOT NULL
)
CREATE TABLE TABLE_B (
ID NUMBER NOT NULL,
NAME VARCHAR2(128) NOT NULL
)
Is this possible in Hibernate, without having to create different subclasses for each table?
|