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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:38:04+00:00 2026-05-31T20:38:04+00:00

my classes seem to be mapped correctly (if I try persist an object it

  • 0

my classes seem to be mapped correctly (if I try persist an object it creates the table in the DB (if it’s missing)) and I can query succesfully, but I can’t get a newly created instance to be persisted to the DB.

I have show SQL queries in console, and it’s not generating the insert query, but it’s trying to select(max) id afterwards

Could someone please help me figure out why?

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
        Session session = sessionFactory.openSession();
        User myUser = new User();
        myUser.setUserId("Acccc");
        myUser.setPassword("abc");
        session.save(myUser);

and class:

@Entity
@Table(name = "users")
@SuppressWarnings("serial")
public class User implements Serializable
{
    //Properties
    @Id
    @Column
    private int id;
    @Column
    private String userId;
    @Column
    private String password;

    //Getters
    public int getId() { return id; }
    public String getUserId() { return userId; }
    public String getPassword() { return password; }

    //Setters
    public void setId(int id) { this.id = id; }
    public void setUserId(String userId) { this.userId = userId; }
    public void setPassword(String password) { this.password = password; }
}

and config:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="nz.co.genesis.healthsafety.stripes.model.User" table="users">
    <id name="id" type="int" column="id" >
    </id>
    <property name="userId" type="java.lang.String" column="userId" not-null="false" length="45" />
    <property name="password" type="java.lang.String" column="password" not-null="false" length="45" />
</class>
</hibernate-mapping>

And DB:

id : PK NN AI
userId varchar45, default NULL
password varchar45, default: null
  • 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-31T20:38:06+00:00Added an answer on May 31, 2026 at 8:38 pm

    I don’t think you configuration of the Transaction Hibernate

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

Sidebar

Related Questions

I'm trying to understand type patterns and generic classes in Haskell but can't seem
I can't seem to get multiple css classes working with php's mail, I've gotten
When defining associations in classes for Datamapper you don't seem to get the associated
Serialized varibale does not seem to retain its state from classes that were extended.
Classes that implement IEnumerable and provide a public void Add(/* args */) function can
Involved classes : Mage_Sales_Model_Quote_Item and Mage_Catalog_Model_Product . I get both of them as a
I have the following mapped classes Trade { ID, AccountFrom, AccountTo } Account {ID,
Type classes seem to be a great possibility to write generic and reusable functions
The Bundle and ContentValues classes seem to have pretty similar functionality. Is there an
The built-in classes for working with audio in Android seem less than ideal. 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.