Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7655527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:32:02+00:00 2026-05-31T12:32:02+00:00

I have simple OneToOne relationship: Data <-> TherapyResult I would like to express the

  • 0

I have simple OneToOne relationship:
Data <-> TherapyResult

I would like to express the following constraints
with JPA.

  1. If a Data entity gets removed the associated TherapyResult should be delete,too
  2. If a TherapyResult entity gets removed the associated Data entity should remain in the db

The first constraint is really easy with JPA as I can add CascadingType.REMOVE

@OneToOne(cascade = { CascadeType.REMOVE, CascadeType.REFRESH })
private TherapyResult therapyResult;

For the second constraint I would like to add something like

@JoinColumn(columnDefinition = "DATA_ID BIGINT CONSTRAINT THERAPYRESULTDTAID FOREIGN KEY (DATA_ID) REFERENCES DATA (ID) ON DELETE SET NULL")

However this does not work. OpenJPA seems to have something similiar, but I want to use JPA 2.0 and EclipseLink. OpenJPA ForeignKey.

Another solution would be using @PreRemove described here, which works but looks a bit “none-best-practices” to me. However just a feeling.

My setup is:
Eclipse 3.7.1
EclipseLink 2.3
Apache Derby 10.8.3 and/or HSQLDB

any help is appreciated,
Muki

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:32:03+00:00Added an answer on May 31, 2026 at 12:32 pm

    You can’t use pure JPA to specify foreign keys … that spec doesn’t include the ability. JDO is the only standard with the ability to define FKs. You have to use implementation specifics, or just define the schema yourself and let the JPA impl run on it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple SSIS package which reads data from flat file and insert into
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple SSIS package where I import data from flat file into SQL
Imagine that you have a Person entity with a one to one relationship with
i have simple question, let's say i have input like this: <input name=somename type=checkbox
I have simple JSF application. Everything works fine, but not navigation. It behaves like
Have simple C# console app which imports text data into SQL. It takes around
I have simple WebView code like this: WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl(http://en.wikipedia.org/wiki/Book); But
I have simple web application based on JSP. Root of application looks like this:
I have the following design: (source: kawoolutions.com ) Simple logic: Foos uses a multi-column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.