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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:45:24+00:00 2026-06-16T20:45:24+00:00

I have an auxiliary standalone application to load the values for entities from some

  • 0

I have an auxiliary standalone application to load the values for entities from some tables, and it is falling because Hibernate is trying to create records without specifying the key value (even if it is specified as @GeneratedValue(strategy=GenerationType.AUTO)).

The bean is:

@Entity
public class Location implements Serializable {

  private static final long serialVersionUID = 1L;

  // startRegion attributes
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private int id = 0;

  @ManyToOne(fetch = FetchType.LAZY)
  private Location parent = null;

  @Column(nullable=false)
  private boolean active = false;

  @OneToMany(mappedBy="parent", cascade=CascadeType.ALL, fetch=FetchType.LAZY)
  private Set<Location> divisions = null;

  @OneToMany(mappedBy="location", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
  @MapKey(name="localeId")
  private Map<String, Location_i18n> descriptions = new HashMap<String, Location_i18n>();

  @Column(nullable=true, length=150)
  private String path = null;

  @Column(nullable=true, length=20)
  private String prismaCode = null;

  @Column(nullable=true, length=5)
  private String shortCode = null;
}

The SQL shown in Hibernate log is missing the id field:

insert into Location (active, parent_id, path, prismaCode, shortCode) values (?, ?, ?, ?, ?)

which obviously causes a constraint violation exception.

The relevant properties from persistence.xml:

  <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect"/>
  <property name="hibernate.show_sql" value="true"/>
  <property name="hibernate.hbm2ddl.auto" value="validate"/>
  <property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

To add to my frustrations, I did a somewhat similar process in a previous process, but I cannot find any difference that is causing the issue.

I have tried both with Hibernate 3.6.10 and 4.1.8 against MS SQL 2008 Express.

Any ideas? Thank in advance.

  • 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-16T20:45:25+00:00Added an answer on June 16, 2026 at 8:45 pm

    It doesn’t work because the AUTO strategy, for your database, consists in relying o the database to generate IDs. The ID column of the table should be an auto-increment column, or you should change the ID generation strategy.

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

Sidebar

Related Questions

have a nice day. I got problem when trying to create an image from
I have a model that requires loading external data from an auxiliary source. A
Sometimes I need to have small auxiliary methods specific for some controller, is it
I have some code that displays a checkmark as the auxiliary view of a
Have a painfully simple blog Post creator, and I'm trying to check if the
Have 2 tables in Access 2007, both lists of certain tasks to be accomplished.
i have following problem from book introduction algorithm second edition by MIT university problem
I have two application servers running Ruby on Rails sharing the same MySQL database
I have a common database joining situation involving three tables. One table, A, is
I wonder if anyone could offer their advice on this one. I have some

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.