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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:15:22+00:00 2026-06-14T03:15:22+00:00

I am new to doctrine. I have a following User class with annotations. The

  • 0

I am new to doctrine. I have a following User class with annotations. The primary key is $userid, which is string. Instead of setting the $userid automatically, I want to set the id manually. How ever I am not sure how to do that?

<?php

namespace models;

/**
 * User
 *
 * @Table(name="user")
 * @Entity
 */
class User
{
/**
 * @var string $userid
 *
 * @Column(name="userid", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
 * @Id
 * @GeneratedValue(strategy="IDENTITY")
 */
private $userid;

/**
 * @var string $fullname
 *
 * @Column(name="fullname", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
 */
private $fullname;

/**
 * @var string $password
 *
 * @Column(name="password", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
 */
private $password;

/**
 * @var string $email
 *
 * @Column(name="email", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
 */
private $email;

/**
 * Get userid
 *
 * @return string $userid
 */
public function getUserid()
{
    return $this->userid;
}

/**
 * Set fullname
 *
 * @param string $fullname
 */
public function setFullname($fullname)
{
    $this->fullname = $fullname;
}

/**
 * Get fullname
 *
 * @return string $fullname
 */
public function getFullname()
{
    return $this->fullname;
}

/**
 * Set password
 *
 * @param string $password
 */
public function setPassword($password)
{
    $this->password = $password;
}

/**
 * Get password
 *
 * @return string $password
 */
public function getPassword()
{
    return $this->password;
}

/**
 * Set email
 *
 * @param string $email
 */
public function setEmail($email)
{
    $this->email = $email;
}

/**
 * Get email
 *
 * @return string $email
 */
public function getEmail()
{
    return $this->email;
}
}

If I even make the id public and set it myself, the doctrine 2 still inserts the default value, which is empty string, leading to Integrity constraint violation. Can someone provide me detailed solution for this.

  • 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-14T03:15:24+00:00Added an answer on June 14, 2026 at 3:15 am

    Remove the @GeneratedValue line from the @Id definition. You’re asking Doctrine to generate the ID for you.

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

Sidebar

Related Questions

I have a doctrine class User which is of this hierarchy Doctrine_Record -> BaseUser
I have the following code: $getmoney = Doctrine::getTable('Countries')->find(1); $insertmoney = new Accounts(); $insertmoney->userid =
I have the following db structure: User > UserRole < Role UserId UserRoleId RoleId
We are using Doctrine 2 for a new project and have run into an
I'm struggling with the following, in a entity class I have a preUpdate lifeCycleCallback
I'm following the directions here: http://symfony.com/doc/2.0/bundles/DoctrineMongoDBBundle/index.html I have installed deps: #deps [doctrine-mongodb] git=http://github.com/doctrine/mongodb.git [doctrine-mongodb-odm]
I'm new to doctrine. I created an bootstrap file like the following one: require_once(dirname(__FILE__)./../conf/general.php);
I have three Doctrine entities: Device, which has a OneToOne relationship with Device\Status, which
I have setup a doctrine listener which is fired on different database actions and
I'm encountering a problem with a Doctrine 2 entity association. I have a User

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.