Cascade primary key with @Mapsid on @OneToOne is not working

Description

In my setup I have an unidirectional one-to-one relation from Person -> Address in the attach test case. The Person has @EmbeddedId which one of it's id's should be cascaded to the Address id.

When I map a @OneToOne relation with @Mapsid with the purpose of cascade the primary key it throw an exception.

If I have read the JPA 2.1 specification correctly it should be supported?

I have attached test in the `ORMUnitTestCase` file

Environment

OSX 10.12.4

Activity

Show:
Flemming Harms
June 2, 2017, 8:48 AM

Thanks for the feedback,

I don't know what I can add more than the test case I already have attached and fails with 5.2.2. And I can confirm I have the same issue with 5.2.9 with the same test case

Thanks!

Jonathan Ihm
June 2, 2017, 12:48 PM

Okay, thanks! I will keep trying to work on this. Could you possible attach a pom.xml file just in case our dependencies aren't exactly the same? Thanks!

Jonathan Ihm
June 2, 2017, 8:26 PM

I was able to get your test running and working after changing your String ids to longs and using a generated value strategy auto for address id. Currently working on test cases where this can be improved upon.

Flemming Harms
June 2, 2017, 9:10 PM

As far I understand one of the purpose of @MapsId is you can cascade one of the composite primary keys to a FK. This mean it should not be necessary to define generated strategy for the FK simple because the PK is cascaded.

That what I'm trying to achieve with @MapsId

Jonathan Ihm
June 5, 2017, 2:46 PM

It seems that in this case, @MapsId is being used in the inverse way and trying to assign the address Id to the person Id. The reason for this is due to Address/Person being flipped as dependent and parent entities (Address would be considered the parent entity in this case). Changing this and manually assigning an Id to address will make it so we don't have to assign a person Id in the embeddable class.

Assignee

Unassigned

Reporter

Flemming Harms

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure