Primary Key « Annotation « JPA Q&A

1. Hibernate creates two primary keys when I only want one

I have a Hibernate class called Expression (simplified here for your viewing pleasure):

public class Expression {
    private long id;


2. Hibernate Annotation, how to define two primary keys

I have a class in java that has a numerical Id and username (a nature primary key). I want that Id and username be primary keys (not combined).

Create table (

3. Hibernate Annotations for Primary Key

Hi, My appliction is on Spring with tomcat-5.5 server. I am using hibernate annotation for generating primary key as auto as @Id @GeneratedValue(strategy = GenerationType.AUTO,generator="test_sequence") @SequenceGenerator(name = "test_sequence",sequenceName="TEST_SEQ") @Column(name = "ID", unique = true, nullable = false) I want to know what generator class should i use in my test.hbm.xml if i use GenerationType.AUTO stratagy in file.Currently i am using ...

5. Hibernate annotations - Shared primary key