We're updating the issue view to help you get more done. 

@EmbeddedId versus @ManyToOne with @PrimaryKeyJoinColumn

Description

This one is a bit tricky, I hope I can give an understandable overview of my problem:

Given are two Classes A and B; and the PK of B basically consists of two instances of A and some other fields.

So Class B has an @EmbeddedId that declares all the fields needed and specifies their respective column names; also Class B has two properties source and target, each annotated with @ManyToOne and pointing to a Class A instance.

Note: Since the fields are declared as part of the @EmbeddedId, I cannot use @JoinColumn. Thus I use @PrimaryKeyJoinColumn to map them.

Now the following problem arises: In the generated SQL (even the table creation statements!) you can see that extra fields target_* and source_* are generated in addition to the fields specified in the EmbeddedId.

Example will follow shortly...

Environment

None

Status

Assignee

Unassigned

Reporter

Philipp Nanz

Components

Affects versions

4.3.0.Final

Priority

Major