I am trying to use Hibernate with hbm2ddl.auto
set to validate
so that Hibernate must respect my DB schema, instead of auto-generating tables around my Java classes.
A lot of my tables are so-called "lookup" or "reference" tables, that essentially consist of id
, name
and tag
fields:
credit_card_types
credit_card_type_id Ex: "12"
credit_card_type_name Ex: "Visa"
credit_card_type_tag Ex: "VISA"
payment_types
payment_type_id Ex: "2"
payment_type_name Ex: "Google Checkout"
payment_type_tag EX: "GOOGLE_CHECKOUT"
etc.
I'd like to model these as follows:
public class BaseLookup {
private Long id;
private String name;
private String tag;
// ...getters, setters and ctors, etc.
}
public class CreditCardTypes extends BaseLookup {
// .. perhaps a few other fields, methods, etc...
}
public class PaymentTypes extends BaseLookup {
// .. perhaps a few other fields, methods, etc...
}
The problem is I don't want Hibernate to search for (validate against) a lookups
table: I want it to validate aginst 2 lookup tables called credit_card_types
and payment_types
respectively.
What annotations/configs do I need to allow this type of Java inheritance but to only create my 2 lookup tables (and not 3)? Thanks in advance!