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

  • Home
  • SEARCH
  • 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 7726853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:18:56+00:00 2026-06-01T05:18:56+00:00

I am working on a web app and I am using JSF and JPA(EclipseLink).

  • 0

I am working on a web app and I am using JSF and JPA(EclipseLink). I have the tables story and story_translate, which are mapped as follows:

@Entity
@Table(name = "story")
public class Story{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Integer id;
private String title;
private String description;
@OneToMany(mappedBy = "story", cascade=CascadeType.ALL)
private List<StoryTranslate> translateList;

    //getters and setters
 }

@Entity
@Table(name = "story_translate")
public class StoryTranslate{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Integer id;
@Column(name="STORY_ID")
private Integer storyId;
    @ManyToOne
@JoinColumn(name="story_id", referencedColumnName="id", updatable=false, insertable=false)
private Story story;

   //some other fields, getters and setters
}

In a ManagedBean I am doing the following:

 StoryTranslate translate = new StoryTranslate(null, sessionController.getEntity().getId(), getAuthUser().getId(), language, 
                    title, description, new Date(), false);
 EntityTransaction transaction = TransactionSingleton.getActiveInstance();
            Story story = storyService.read(sessionController.getEntity().getId());
            if (story != null){
                if (story.getTranslateList() == null){
                    story.setTranslateList(new ArrayList<StoryTranslate>());
                }
                story.getTranslateList().add(translate);
                translate.setStory(story);
            }
            transaction.commit();

When I try to create a new StoryTranslate, I get a DatabaseException, saying the story_id cannot be null.

I have managed relationships before, but I have never seen this error.

Where is the problem?

EDIT: I am sorry, but I have forgotten about another part of the mapping(must be the lack of sleep).

  • 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-01T05:18:58+00:00Added an answer on June 1, 2026 at 5:18 am

    The problem is that your declare the storyId property in the StoryTranslate class for the STORY_ID column but when adding a new StoryTranslate , you do not set any value to its storyId property and I believe STORY_ID column has a NOT NULL constraint and that why you get the exception saying that story_id cannot be null.

    The problem should be fixed once you set the storyId property of the StoryTranslate instance before committing the transaction .

    But it is strange that you map the STORY_ID column to two different properties ( storyId and story) of the StoryTranslate class . Actually you do not need to declare storyId property as this value can be retrieved from the story instance . I suggest you change the mapping of StoryTranslate to the following and your code should work fine without any changes.

    @Entity
    @Table(name = "story_translate")
    public class StoryTranslate{
       @Id
       @GeneratedValue(strategy = GenerationType.SEQUENCE)
       private Integer id;
    
       @ManyToOne
       @JoinColumn(name="story_id")
       private Story story;
    
       //some other fields, getters and setters
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web app using C# and asp.net I have been
I am working on an iPhone Web App using HTML & CSS. I have
Using Visual Studio 2008 and VB.Net: I have a working web app that uses
I am using working on web app which had a DIV in which latest
I am working on a web app using JSF w/Seam. I want to be
Im working in a Web App with Java and JSF. I have a simple
I am working on a web-app using Django 1.3 and Python2.6. I have to
Im working on an web app using c#. I have in my code the
I have been working on a small web app using the Stripes framework. Now
I am working on a web app using MVC, where all pages have header

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.