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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:54:31+00:00 2026-05-30T22:54:31+00:00

While working on my first app in Hibernate. While trying to retrieve a User

  • 0

While working on my first app in Hibernate. While trying to retrieve a User object from the DB i am getting the following exception:

org.hibernate.TypeMismatchException: Provided id of the wrong type for
class org.cw.form.User. Expected: class java.lang.Integer, got class
java.lang.String
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:109)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:823)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:816)

I have created the USERS table with the following postgreSQL:

CREATE SEQUENCE user2_id_seq; 

CREATE TABLE USERS(id integer NOT NULL DEFAULT nextval('user2_id_seq'), user_name   varchar(45) NOT NULL UNIQUE , password varchar(45) NOT NULL, email varchar(45) NOT NULL, PRIMARY KEY (id));

And the User entity is defined as such:

@Entity @Table(name="USERS") public class User {

@Id
@Column(name="ID")
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;

@Column(name="USER_NAME", unique = true)
private String userName;

@Column(name="PASSWORD")
private String password;

@Column(name="EMAIL")
private String email; .. all the getters and setters...

I am I missing something?

  • 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-30T22:54:33+00:00Added an answer on May 30, 2026 at 10:54 pm

    It would be easier to answer if you would show how do you retrieve Users. Based to message:

    Provided id of the wrong type for class org.cw.form.User. 
    Expected: class java.lang.Integer, got class java.lang.String
    

    I guess you are providing String instead of correct type (Integer):

    String userID = "1"; //Should be Integer userID = 1 instead
    session.get(User.class, userID); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While working on an existing project I suddenly got the following error when trying
I am working on an app that auto saves content while a user works
I'm working on an app that can retrieve images from the web. Rather than
While working in a Java app, I recently needed to assemble a comma-delimited list
While working on an Xcode project i keep getting the spinning wheel while switching
I am working on my first desktop app that queries LDAP. I'm working in
I am getting started with HAML and am working on my converting my first
I'm currently working on an app that works with Twitter, but while developing/testing (especially
First off, I'm working on an app that's written such that some of your
In a web app I'm working on, I'm capturing onBeforeUnload to ask the 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.