my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes Naming child-parent relation with JPA Annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Naming child-parent relation with JPA Annotation" Watch "Naming child-parent relation with JPA Annotation" New topic

Naming child-parent relation with JPA Annotation

maya pedersen

Joined: May 27, 2004
Posts: 6
Hi everybody,

I'm having a slight problem I thought someone might know how to solve:

I have two classes, Element and Article. Element is the abstract parent class of Article and they're tied
together by an id. It's a OneToOne relationship, a given parent can only have one child.

I have JPA autogenerate my tables and my issue is that the constraint between Element and Article, that is
created in the database, has a jibberish name (like 'FK7B3CBC94A2DA0E17'). What I would like is to give said
constraint a name so I have don't have to manually search my db browser to find out what said name is.

I know the @ForeignKey annotation and have used it in other scenarios but it doesn't seem to fit here.

Do any of you guys have any idea how I go about this?

A light version of my classes below:

This is the parent class, Element

This is the child class, Article, connected to it's parent by the ID

Sincere thanks in advance,


live long and prosper
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Naming child-parent relation with JPA Annotation
Similar Threads
JPA Multiple Foreign Key Join
Multiple Column Join
two parents, one child, ora-02291
Annotated Entity Bean Inheritance
one to one unidirectional mapping in jpa