LoginSignup
0
0

More than 3 years have passed since last update.

hibernateの複合キー

Last updated at Posted at 2020-02-12
@Entuty
@Table(name="sample")
public class SampleRecord {

    @Column(name = "id")
    private long id;

    @Column(name = "name")
    private String name;

    // 省略
}
Exception in thread "main" org.hibernate.AnnotationException: No identifier specified for entity: com.sample.jpa.SampleRecord

@Entityを使う場合は@Idを指定しないといけないっぽい

@Embeddable
@Table(name="sample")
public class SampleRecord {

    @Column(name = "id")
    private long id;

    @Column(name = "name")
    private String name;

    // 省略
}

@Embeddableを使ってみるとコンパイルエラーすることなくできました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0