These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Error: GenerationType.IDENTITY requires id.
PostPosted: Sun Apr 12, 2009 6:13 pm 
Newbie

Joined: Tue Apr 07, 2009 9:00 pm
Posts: 9
I'm using Hibernate 3.3.1 with Postgres.

My persistence.xml contains the following:
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>

I have
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

@Column(...)
private String name;

I see the db created the column as bigserial, which is what I want.

When I go to persist the object it throws an error saying that the id parameter is blank. Am I missing something here?

org.postgresql.util.PSQLException: No value specified for parameter 2.

Hibernate:
insert
into
users
(name, id)
values
(?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 11:20 am 
Newbie

Joined: Tue Apr 07, 2009 9:00 pm
Posts: 9
Also, why would one not want to use IDENTITY when the database supports it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.