I have Java EE application with Hibernate mapped classes (I use *.hbm.xml mappings). Now I need to remake mappings with JPA annotations. All is fine but I can't create correct mapping with my Map property.
@Entity
@Table(name = DataBaseConstants.EMPLOYEE_TABLE)
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name = DataBaseConstants.EMPLOYEE_ID, sequenceName = DataBaseConstants.EMPLOYEE_SEQ)
@GeneratedValue(generator = DataBaseConstants.EMPLOYEE_ID)
@Column(name = DataBaseConstants.EMPLOYEE_ID)
private long id = 0;
@Column(name = DataBaseConstants.EMPLOYEE_NAME)
private String name = null;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = DataBaseConstants.ADDRESS_ID_FK)
private Address address = null;
private Map<Office, Position> officePositions = null;
Here is part of data model in data base. DB MODEL IMAGE (Sorry I can't post images) Help me please to mapping officeEmployee MAP
In Hibernate i used this way and everything was OK.
<map name="officePositions" table="EMPLOYEE_POSITION_OFFICE" lazy="false"
fetch="join" batch-size="100">
<key>
<column name="EMPLOYEE_ID"></column>
</key>
<map-key-many-to-many class="com.example.jpajdbctask.entities.Office">
<column name="OFFICE_ID">
</column>
</map-key-many-to-many>
<many-to-many column="POSITION_ID"
class="com.example.jpajdbctask.entities.Position" />
</map>