@@ -0,0 +1,1920 @@
+package com.vladmihalcea.book.hpjp.hibernate.association;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractTest;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * %3Ccode%3ESortIndexCollectionInheritance%3C/code%3E -%0A *%0A * @author Vlad Mihalcea%0A */%0Apublic class TwoMapsIdsTest extends AbstractTest %7B%0A%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D %7B%0A            Address.class,%0A            Location.class,%0A            Person.class,%0A        %7D;%0A    %7D%0A%0A    @Test%0A    public void testScopeIdentity() %7B%0A        doInJPA(entityManager -%3E %7B%0A            Address address = new Address();%0A            address.id = 1L;%0A%0A            Location location = new Location();%0A            location.id = 1L;%0A%0A            Person person = new Person();%0A            person.personId = 1L;%0A            person.address = address;%0A            person.location = location;%0A%0A            entityManager.persist(address);%0A            entityManager.persist(location);%0A            entityManager.persist(person);%0A        %7D);%0A%0A        doInJPA(entityManager -%3E %7B%0A            Person person = entityManager.find(Person.class, 1L);%0A            assertEquals(Long.valueOf(1L), person.address.id);%0A            assertEquals(Long.valueOf(1L), person.location.id);%0A        %7D);%0A    %7D%0A%0A%0A%0A    @Entity(name = %22Address%22)%0A    public static class Address %7B%0A%0A        @Id%0A        private Long id;%0A    %7D%0A%0A    @Entity(name = %22Location%22)%0A    public static class Location %7B%0A%0A        @Id%0A        private Long id;%0A    %7D%0A%0A    @Entity(name = %22Person%22)%0A    public static class Person  %7B%0A%0A        @Id%0A        private Long personId;%0A%0A        @OneToOne%0A        @MapsId%0A        @JoinColumn(name = %22personId%22)%0A        private Address address;%0A%0A        @OneToOne%0A        @MapsId%0A        @JoinColumn(name = %22personId%22)%0A        private Location location;%0A    %7D%0A%7D%0A

Add test for multiple mapsid