Is it possible to map an object to only part of an existing table in a database? For example:
public class Account {
private Integer id;
private Integer accountNumber;
@Id
public Integer getId() {
return this.id;
}
@Column(nullable=false)
public Integer getAccountNumber() {
return this.accountNumber;
}
}
In the database (just for the sake of the question):
Account
- id
- accountnumber
- lastmodified
- localbranchid
Yes, you can only map a portion of the columns in the database table to the
Accountclass (you simply just map the columns you are interested in), but if you ever have a need to insert newAccounts into the database and the unmapped columns have not-null constraints and no database default values, you will run into problems.