-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with @GeneratedValue annotation with Hibernate
PostPosted: Thu Jan 10, 2008 11:43 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 9:24 am
Posts: 28
Hi all,
I've mapped my entity identifier property in order to use the default identifier generator like below:
Code:
@Entity
@Table(name="Article")
public class Article implements Serializable
{
@Id
@GeneratedValue
@Column(name="codeArticle",insertable=false)
private Long codeArticle;
private String auteur;

public Article()
{
}

...

}


The corresponding datebase column type is identity. And with sybase, this column is automatically generated.
But when I try to persist an instance, I don't know why Hibernate is adding the codeArticle column in the generated sql statement.
Here is the code that is generated by Hibernate:
Quote:
Hibernate: insert into Article (codeArticle, auteur, codeCategorie, dateEnreg, codeSupport, titre) values (null, ?, ?, ?, ?, ?)
16:24:52,171 ERROR [JDBCExceptionReporter] The column codeArticle in table Article does not allow null values.


Can someone tells me how to say to Hibernate no to put the codeArticle column in the insert statement ?

thanks in advance.
Meissa


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 11, 2008 6:00 am 
Newbie

Joined: Mon Sep 24, 2007 2:55 pm
Posts: 13
Add "(strategy=GenerationType.IDENTITY)" to GeneratedValue and see if this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 11, 2008 10:34 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 9:24 am
Posts: 28
lafr wrote:
Add "(strategy=GenerationType.IDENTITY)" to GeneratedValue and see if this helps.


When the primary key generation strategy is not set, it's the default that apply. And the default is GenerationType.AUTO. In my case, (since I'm using sybase, it will be GenerationType.IDENTITY.

I have found the problem.
The dialect that was defined in the persistence.xml was not the one that suited to sybase.

Thank you for your reply.
Meissa


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.