-->
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: @GenerateValue with a compound primary key?
PostPosted: Thu Sep 07, 2006 10:29 pm 
Newbie

Joined: Fri Jan 21, 2005 2:30 pm
Posts: 5
Hi there --

I am trying to create a primary key that is partially set by data and partially generated. In this example databaseId is set to a value with entityId to be generated.

I tried to use @EmbeddedId in conjunction with @GeneratedValue. This doesn't seem possible as the @GenerateValue is ignored on TransPolId.id because it doesn't have an @Id annotation

@Entity
public class IdUsing1 {
@EmbeddedId
public TransPolId id;
public String value;
}

@Embeddable
public class TransPolId implements Serializable {
@GeneratedValue
public Long id;
public Integer databaseId;
}

I also tried using @IdClass:

@Entity
@IdClass(TransPolId.class)
public class IdUsing1 {
@Id @GeneratedValue
public Long id;
@Id
public Integer databaseId;
public String value;
}

@Embeddable
public class TransPolId implements Serializable {
public Long id;
public Integer databaseId;
}

but here too the @GenerateValue is ignored. How can I get a primary key that is partially automatically generated?

Hibernate version: Hibernate 3.2.0.cr2 (HAN:3.2.0.cr1)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 8:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
correct this is not possible and is considered a somewhat broken moden since the generated id is unique in itself alread. Search the forum for similar issues, people were able to work around that using usertypes

_________________
Emmanuel


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.