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 8434009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:32:30+00:00 2026-06-10T06:32:30+00:00

My Content has a Map of Footnote , and Footnote has a content_id column

  • 0

My Content has a Map of Footnote, and Footnote has a content_id column which is a foreign key back to Content. Unfortunately saving my Content with the footnoteMap containing a Footnote throws the following error:

ERROR: Cannot insert the value NULL into column 'content_id', table 'CMT_DEV.dbo.footnote'; column does not allow nulls. INSERT fails.
SEVERE: org.springframework.dao.DataIntegrityViolationException: Cannot insert the value NULL into column 'content_id', table 'CMT_DEV.dbo.footnote'; column does not allow nulls. INSERT fails.; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Cannot insert the value NULL into column 'content_id', table 'CMT_DEV.dbo.footnote'; column does not allow nulls. INSERT fails.

I must be missing something with the annotations required to make this work, but I can’t figure out what it is.

Here is my JPA mapping:

public class Content implements EntityModel, Serializable {
    @OneToMany(mappedBy="contentId", cascade=CascadeType.ALL)
    @MapKey(name="number")
    @OrderBy("number ASC")
    private Map<Integer, Footnote> footnoteMap;

    ....
}

public class Footnote implements EntityModel, Serializable {
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name = "content_id", referencedColumnName= "id")
    private Content contentId;

    ....
}

* update *

Keep in mind that the point at which a Footnote is added, the content item has not been saved.

  • 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-06-10T06:32:32+00:00Added an answer on June 10, 2026 at 6:32 am

    First of all, note that it’s your responsibility to keep both sides of bidirectional relationships in consitent state, i.e. when you add a Footnote to Content you should also set its contentId appropriately.

    If you did so but it still fails, then perhaps it’s a mismatch between database schema and Hibernate mapping. Note that content_id column has a not null constraint, but nothing in the mapping tells Hibernate that such a constraint exists. Try @ManyToOne(cascade=CascadeType.ALL, optional = false).

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

Sidebar

Related Questions

I am trying to open a file which normally has content, for the purpose
I created a content type which has some fields and i want this fields
I have two tables, pages and revisions. Revisions has a foreign key to a
I am using a shorthand if statement to check if content has an italic
I have some content that I am loading using jquery ajax. The content has
I have a reviews/ratings web application, a la Digg. My django app content has
I have a div with some content that has a negative position relative. I
I have a HTML table. Each cell has content of different length. For this
as I understood from ASP.net MVC 4 Release notes, is that it has Content
Content type Events has intro, body and an event date field (using Date module).

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.