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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:59:30+00:00 2026-06-11T12:59:30+00:00

Right now I’m working on small project, submitting very simple jobs and I’m working

  • 0

Right now I’m working on small project, submitting very simple jobs and I’m working on saving this to the database. Consider this case :

public class Myjob{
   int id;
   int name;
   MyJobConfiguration configuration;
   //etc
}

public class MyJobConfiguration{
     //bunch of configuration fields
}

I have these configurations in separate class as you see, which means I want to add/update/delete configurations independent of my job object.

My goal was to create configuration first and then while creating a job assign an existing configuration to it.

So more than one job can use same configuration object.

How would I do that? I’ve already got an idea how to do it in the database, I would connect primary key of configuration to foreign key in the myJob class, but it seems different in hibernate. Does anyone have example how to do that ?

I found this one as I thought that is it http://www.mkyong.com/hibernate/hibernate-one-to-one-relationship-example-annotation/ but it seems not

  • 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-11T12:59:31+00:00Added an answer on June 11, 2026 at 12:59 pm

    You want a one to many relationship, not a one to one as described in the linked article.

    You’ve got a clear idea of how you want the relationship to work, which is nice. Based on what you’ve said, I would make MyJobConfiguration look like this:

    public class MyJobConfiguration {
        @OneToMany(mappedBy = "configuration")
        private List<MyJob> jobs;
    
        //bunch of configuration fields
    }
    

    and MyJob look like this:

    public class Myjob{
        int id;
        int name;
    
        @ManyToOne
        @JoinColumn(name = "configuration_id", nullable = false)
        MyJobConfiguration configuration;
        //etc
    }
    

    I might even be inclined to give MyJob a constructor that takes a MyJobConfiguration instance, and make the MyJob() default constructor package-private scoped so that Hibernate can still use it, but callers can’t.

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

Sidebar

Related Questions

Right now I have a small database with two tables that look something like
Right now when I run this it keeps clicking on the same button every
Right now, I have a domain entity named StyleBundle. This StyleBundle takes a list
right now i have this <script type='text/javascript'> $(#beau).click(function(){ $(#beau).animate({margin-Top: 738px}, fast); }); </script> and
Right now I have a mysql database with a table userphone(id, phone, type,userid) and
this is what i have right now Drawing an RSS feed into the php,
Right now, I miss quite some issues for my project hosted on GitHub. I
Right now I'm doing this: class MyTest(Base): __tablename__ = 'mytest' id = Column(Integer, primary_key
Right now I've been maintaining a second sandbox project where I test concepts and
Right now our team's ASP.NET MVC 2.0 web project takes about 4 minutes to

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.