-->
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.  [ 4 posts ] 
Author Message
 Post subject: @GeneratedValue is getting set to null - why ??
PostPosted: Thu Jan 04, 2007 12:34 am 
Newbie

Joined: Mon Dec 22, 2003 9:12 am
Posts: 6
Location: Ohio
When using the GeneratedValue annotation, Hibernate is generating a null ID.

Why is this??

I have a simple 'Artist' class with an id marked as such:

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="ID")
private Long id;

INFO - Hibernate EntityManager 3.2.0.CR2
INFO - Hibernate Annotations 3.2.0.CR2
INFO - Hibernate 3.2 cr4

Running a simple test:

tx.begin();
manager.persist(artist);
tx.commit();

Gives a null for the GeneratedID:

Hibernate: insert into ARTIST (ID, name, CGR_ID) values (null, ?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 8:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
becasue your DB use an identity column by default. Please use the standard response next time, it would have shown your DB.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Identity columns in H2
PostPosted: Thu Jan 04, 2007 3:18 pm 
Newbie

Joined: Mon Dec 22, 2003 9:12 am
Posts: 6
Location: Ohio
Ya, I forgot that bit. Sorry.

DB is H2.

I am not familiar with identity columns - what do info do I need to provide to get that to work?


Thanks!

--Bil[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 06, 2007 12:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
artist.getId() != null after commit.

_________________
Emmanuel


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