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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:00:26+00:00 2026-06-07T08:00:26+00:00

I need to set a auto increment for a field in my table. This

  • 0

I need to set a auto increment for a field in my table.

This is my Entity class:

@Entity
@Table(name = "UserLogin")
public class User implements Serializable {

private int id;
private String username;
private String password;
private String fname;
private String lname;
private String emailId;
private boolean loginperson;
private String manager;

@Id
@GeneratedValue
@Column(name = "empolyeeId")
public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

@Column(name = "username", nullable = false)
public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

@Column(name = "password", nullable = false)
public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

@Column(name = "firstName", nullable = false)
public String getFname() {
    return fname;
}

public void setFname(String fname) {
    this.fname = fname;
}

@Column(name = "lastName", nullable = false)
public String getLname() {
    return lname;
}

public void setLname(String lname) {
    this.lname = lname;
}

@Column(name = "emailId", nullable = false)
public void setEmailId(String emailId) {
    this.emailId = emailId;
}

public void setManager(String manager) {
    this.manager = manager;
}

@Column(name = "loginperson", nullable = false)
public boolean isLoginperson() {
    return loginperson;
}

public void setLoginperson(boolean loginperson) {
    this.loginperson = loginperson;
}

@Column(name = "manager", nullable = false)
public String getManager() {
    return manager;
}

public String getEmailId() {
    return emailId;
}

Here I am not able have set Generated value for the id field.But it is not creating the the auto increment for the id field.

I have tried with

@GeneratedValue(strategy=GenerationType.AUTO)

and

@GeneratedValue(strategy=GenerationType.IDENTITY)

But the table is not getting created in mysql database.

I am getting the following log.

    ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table UserLogin (empolyeeId integer generated by default as identity (start with 1), emailId varchar(255), firstName varchar(255) not null, lastName varchar(255) not null, loginperson bit not null, manager varchar(255) not null, password varchar(255) not null, username varchar(255) not null, primary key (empolyeeId))
    ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'generated by default as identity (start with 1), emailId varchar(255), firstName' at line 1
  • 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-07T08:00:28+00:00Added an answer on June 7, 2026 at 8:00 am

    Try using these lines for your ID:

    @Id
    @GenericGenerator(name="gen",strategy="increment")
    @GeneratedValue(generator="gen")
    @Column(name = "ID", unique = true, nullable = false, precision = 15, scale = 0)
    private Long id;
    

    It’s better to use Long, but if you insist using int, simply change the type to int.

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

Sidebar

Related Questions

The table I am working with does not have a standard auto-increment field to
My problem is i have set a table auto commit false. I need to
I need my application installer set the program to auto-startup for all users. Then
I need set a cultureinfo different of others in a currency field. Metadata: [Display(ResourceType
I need Set collection, where its items will be identified by items class. Something
All, I am trying to create a table to receive user inputs (UGC). This
I have mysql table with following fields id (which auto increments) title,name,age,institution,iod the fields
I need to index a varchar field on my table in MS SQL Server
Need set zoom for camera preview...
Need to set some attributes of button. For example Checked. I guess it is

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.