• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Naming child-parent relation with JPA Annotation

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,

Maya
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic