I have two tables that I want to wrap in a view:
CREATE VIEW myview AS
SELECT 1 as type, key, some_col FROM table1
UNION ALL
SELECT 2 as type, key, some_col FROM table2;
Then, I want to define an EJB entity to wrap the view:
@Entity
@Table (name="myview")
public class MyEntity {
@Id
@Column(name="type")
private Integer type;
@Id
@Column(name="key")
private Integer key;
@Column(name="some_col")
private String someCol;
}
Note that the EJB is identified by type + key (that form a unique identifier). Is this approach correct?
Aucun commentaire:
Enregistrer un commentaire