Hibernate Tips: How to Share the Primary Key in a One-to-One Association
|

Hibernate Tips: How to Share the Primary Key in a One-to-One Association

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: I need to map a one-to-one association in which the primary key value of one entity is also used…

Hibernate Tips: How to model an association that doesn’t reference primary key columns
|

Hibernate Tips: How to model an association that doesn’t reference primary key columns

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: I have to map a legacy table model with Hibernate. It contains a many-to-one association that uses a non-primary…

How to override the primary key generation strategy

Hibernate Tips: How to override the primary key generation strategy

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: You explained that the GenerationType.SEQUENCE is the most efficient primary key generation strategy and that MySQL doesn’t support it….

@NaturalId – A good way to persist natural IDs with Hibernate?

@NaturalId – A good way to persist natural IDs with Hibernate?

In the real world, most objects have a natural identifier. Typical examples are the ISBN number of a book, a company’s tax identifier or a person’s social security number. You could, of course, use these identifiers as primary keys. But most often, it’s a better idea to generate numeric, surrogate keys. They are easier to…