vladmihalcea / high-performance-java-persistence

The High-Performance Java Persistence book and video course code examples
Apache License 2.0
1.31k stars 489 forks source link

Unidirectional OneToOne has @GeneratedValue inside the Post_Details. #42

Closed CazacuRadu closed 5 years ago

CazacuRadu commented 5 years ago

@vladmihalcea Check the UnidirectionalOneToOne test, you have there the @GeneratedValue even tho in your article you said it should be left out.

vladmihalcea commented 5 years ago

If you read the @OneToOne article carefully, you'll see that the @GeneratedValue is not needed when sharing the PK, meaning you are using the @MapsId annotation. The UnidirectionalOneToOneTest does not use @MapsId, hence you still need @GeneratedValue.