-->
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.  [ 5 posts ] 
Author Message
 Post subject: Auto id generation when custom class is used as identifier.
PostPosted: Tue May 02, 2006 7:12 am 
Beginner
Beginner

Joined: Wed Jun 09, 2004 8:10 am
Posts: 28
Hibernate 3.2RC1.

I need to use my own class for primary keys. Usually they contain int (in this case it's id).

Code:
@Id
@AttributeOverrides({
    @AttributeOverride(name = "id", column = @Column(name="SYSTEMUSERKEY"))
})
private SystemUserPK primaryKey;


Code:
@Embeddable
@AccessType("field")
public class SystemUserPK implements IPrimaryKey, Cloneable {
...
    private int id;
}


Problem here is that I don't know how to enable auto id generation for these keys. Can anyone help me with this (directions where to look)?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 2:25 am 
Beginner
Beginner

Joined: Wed Jun 09, 2004 8:10 am
Posts: 28
I implemented and configured my own identifiers generator but it won't be invoked anyway.

Hibernate just says that id must be set manually prior invoking save(...).

Can anyone help me?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 6:13 am 
Beginner
Beginner

Joined: Wed Jun 09, 2004 8:10 am
Posts: 28
It seems that it's never tried to use specified id generator. :(

Is this correct:

Code:
@GenericGenerator(name = "SystemUserPK_Generator", strategy = "class.name")


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 6:28 am 
Beginner
Beginner

Joined: Wed Jun 09, 2004 8:10 am
Posts: 28
Sorry forgot to add:

Code:
@GeneratedValue(generator = "SystemUserPK_Generator")

:( Sorry. Feel ashamed...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 6:39 am 
Beginner
Beginner

Joined: Wed Jun 09, 2004 8:10 am
Posts: 28
Ok. I fixed this problem. I created my own key generator which uses supplied hibernate generators and constructs my own primary keys with generated id.

I am starting to like hibernate more and more. :D Good job guys! :D


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