I am using hibernate 3 and Xdoclet to build the mapping files and export the schema of my SQL Server 2005 database. I am using 'table per subclass' approach to map a class hierarchy to a relational database. Although, I am having difficulty specifing the data type for foreign key of the subclass.
For example, say I have three two classes: Payment and CashPayment. Payment is the superclass and CashPayment is the subclasses. If I don’t specify the data type, hibernate will interpret my id type, which is a Long, to have a data type to be numeric(19,0). My Project's business rules specify that this data type needs to be a bigint. I am able to change the primary key’s data type for the superclass. However, I am not able to change the data type of the subclasses that extends my superclass.
Does somebody know the xdoclet annotation to enforce the key in the subclass to be a specified datatype such as a bigint?
Code Example:
/**
* @hibernate.class
*/
public class Payment {
private Long id;
private Double amount;
/**
@hibernate.id generator-class="hilo" unsaved-value="null"
* @hibernate.column name="ID" sql-type="bigint"
* @hibernate.property name="ID" type="long"
*
*/
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
/**
* @hibernate.property
*/
public Double getAmount() {return amount;}
public void setAmount(Double amount) {this.amount = amount;}
}
/**
* @hibernate.joined-subclass
* @hibernate.joined-subclass-key
* column="id"
*/
public class CashPayment extends Payment {
private String something;
/**
* @hibernate.property
*/
public String getSomething() {return something;}
public void setSomething(String something) {this.something = something;}
}
|