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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:52:04+00:00 2026-05-28T19:52:04+00:00

I have designed a table (in postgres) where ‘id’ column is autoincremented via its

  • 0

I have designed a table (in postgres) where ‘id’ column is autoincremented via its SEQUENCE entity.
But when I began use hibernate I met the problem …. due creating the insert statement, it use the follow statement

INSERT INTO mytable (id, name) VALUE (0, ‘blablabla’)

…

but I want it make somethink like that:

INSERT INTO mytable (name) VALUE (‘blablabla’)

… Postgres have to generate id automatically (at least when I ran such scripts withing sql editor, it worked)

I belive it can be configured, but I don’t know how…

Here is my part of my .hbm.xml:

<hibernate-mapping>
    <class name="com.cse.database.bean.Category" table="category">
        <id name="id" type="int">
            <column name="id" />
            <generator class="assigned" />
        </id>
        <property name="name" type="string">
            <column name="name" length="100" not-null="true" unique="true" />
        </property>
    </class>
</hibernate-mapping>
  • 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-28T19:52:05+00:00Added an answer on May 28, 2026 at 7:52 pm

    When you specify a <generator>, you’re telling Hibernate how to create the ID. assigned means your application is doing it (which you don’t want). You can specify a Hibernate class or even an application class to do it, which you don’t want either. identity means the database does it for you, which is what you want. In some databases you can use sequence (which will query the sequence generator to get the ID, then write the record), and Hibernate allows you to use native to specify the most applicable for your DB.

        <id name="id" type="int">
            <column name="id" />
            <generator class="identity" />
        </id>
    

    apparently works in this case.

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

Sidebar

Related Questions

I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have designed a custom section handler before but I'm faced with a problem
I have designed a table called USER_REQUESTS . It has a field called STATUS
I am having 20 rows in a table view, and I have designed (or
I have a legacy object model that has content objects and a table designed
I have a simple customers table designed this way (I report only some fields,
I have an table which use an auto-increment field (ID) as primary key. The
I have a table which was designed as a key-value table, like ID |
I have a (cake) php function designed to update entries in a MySQL table;
I have an JPA entity like this: @Entity @Table(name = category) public class Category

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.