I have a table where the table structure is like this
package com.abc.domain;
@Entity
@Table(
name = "ENTITY_DTL"
)
public class MyEntityDtl implements Serializable {
private static final long serialVersionUID = 1L;
private static final int NATLTY_CD_LENGTH = 3;
@Id
@Column(
name = "MY_ENTITY_DTL_ID",
unique = true,
nullable = false
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "myEntityDtlIdSeq"
)
@SequenceGenerator(
name = "myEntityDtlIdSeq",
sequenceName = "MY_ENTITY_DTL_ID_SEQ",
allocationSize = 1
)
private Long MyEntityDtlId;
@ManyToOne(
fetch = FetchType.LAZY
)
@JoinColumns({@JoinColumn(
name = "ENTITY_ID",
referencedColumnName = "ENTITY_ID",
nullable = false
), @JoinColumn(
name = "ENTITY_TYPE_CD",
referencedColumnName = "ENTITY_TYPE_CD",
nullable = false
)})
private MyEntity myEntity;
/*
other columns and their getter setter
*/
}
Here- what i want to achieve is - something like this
Join MyEntityDtl table with Abc table using this columns - ENTITY_ID and ENTITY_TYPE_CD .
How can i achieve it without using MyEntity table in the query.
As that will cost me additional join in this situation
Any help is appreciated, thank you in advance