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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:45:27+00:00 2026-05-25T00:45:27+00:00

I have some issue with save object with one to many relationship. In my

  • 0

I have some issue with save object with one to many relationship. In my problem One UserGrop has many UserPermissions. Forthat relation ship I have create my domain class like this:

@Entity
@Table(name = "tbl_usergroup")
public class UserGroup implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)    
    @Column(name="userGroupId")
    private long userGroupId;

    @Column(name = "userGroupName")
    private String userGroupName;

    @OneToMany(cascade=CascadeType.ALL,mappedBy="userGroup",fetch=FetchType.EAGER)
    private Set<UserPermissions> userPermissions = new HashSet<UserPermissions>(0);



}

@Entity
@Table(name = "tbl_group_permissions")
public class UserPermissions implements Serializable {

    @Id
    @GeneratedValue
    private Long userPermissionId;

    @ManyToOne(cascade =CascadeType.ALL)     
    @JoinColumn(name="userGroupId",nullable=false)
    @ForeignKey(name = "userGroupId")
    private UserGroup userGroup;


}

But When saving UserGroup, it save hat UserPermisions Objects also. There with the table it does not have any relationship(when retrieving UserGroup object, it doesn’t return Set of UserPermisions objects).

DB:

+------------------+-------------+
--+
| userPermissionId | userGroupId |
e |
+------------------+-------------+
--+
|               33 |        NULL |
  |
|               34 |        NULL |
  |
|               35 |        NULL |
  |
|               36 |        NULL |
  |
|               37 |        NULL |
  |
|               38 |        NULL |
  |
|               39 |        NULL |
  |
|               40 |        NULL |
  |
+------------------+-------------+
--+
8 rows in set (0.00 sec)

Can any body help me to solve this issue?

  • 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-25T00:45:28+00:00Added an answer on May 25, 2026 at 12:45 am

    In the @OneToMany on UserGroup.userPermissions you have mappedBy="userGroup". This means the userGroup property in UserPermisions is responsible for the relation. I guess you don’t set that property and upon saving it’s still null.

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

Sidebar

Related Questions

I'm having some difficulty creating nested objects between a one-to-many relationship. My models are
I have a very painful issue here, if some one could help ? I
I have some issue with a Perl script. It modifies the content of a
I have some unsolved issue with threads. It's my first time doing it. I
i have an issue i could use some help with, i have python list
I have a design issue that I would appreciate some input on. I would
I have an issue with System.Threading.Timer. I am scheduling some actions using a time
I'm working on some screen scraping software and have run into an issue with
We're having a small issue and could use some help - we have the
I'm using XPreformatted to print some preformated text and I have an issue with

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.