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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:31:26+00:00 2026-06-09T22:31:26+00:00

I have the User Login Registration Page. Now on the same Page i have

  • 0

I have the User Login Registration Page.

Now on the same Page i have one more Forms i.e UserInterests.

Now i have the PostPersist function which creates new UserProfile after User is Persisted

Now UserProfile is linked with User ID and UserInterests is linked with UserProfile ID

Now the client wants UserInterests on same User page but i have problem that UserProfile is not yet created. Now how can persist them. Is there any way

  • 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-09T22:31:28+00:00Added an answer on June 9, 2026 at 10:31 pm

    I don’t think you can get the ID before flushing.

    You could create an association between the models, that way Doctrine will take care of the id’s when saving and you can retrieve your UserInterests with something like:

    $user->getProfile()->getInterests();
    

    So you would have your User model with a property that holds your UserProfile:

    /**
     * @OneToOne(targetEntity="UserProfile")
     * @JoinColumn(name="profile_id", referencedColumnName="id")
     **/
    private $profile;
    

    and your UserProfile class should have a property to hold the UserInterests model.

    /**
     * @OneToOne(targetEntity="UserInterests")
     * @JoinColumn(name="interests_id", referencedColumnName="id")
     **/
    private $interests;
    

    You can now create an empty $userProfile model (to link the others together, the actual filling can be done in your postPersist function) and a $userInterests model, associate them by

    $interests = new UserInterests();
    
    // create an empty UserProfile, and fill it in your PostPersist function, 
    // that way it can already be used to link the User and UserInterests
    $profile = new UserProfile();
    
    $profile->setInterests($interests);
    $user->setProfile($profile);
    

    Now Doctrine will fill in the ids when persisting and you don’t need to worry about them.

    More information here

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

Sidebar

Related Questions

I have built a site which requires user to login. Now I have decided
i have created one login and register view in that view after login user
I have my login and registration forms in elements that reference the users controller
I created a django application with a user login/registration page. I am trying to
I have a registration page that receives tokens ad parse them and login the
I have a JSP page that has 2 forms running on Tomcat 6. One
I have created a django app. It has got a user login/registration on the
I have two pages for registration. On one I get the user data into
Upon user login I check their roles. If they have no roles I want
I have two sql tables for user login, store and retrieve data according 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.