How to get DEPARTMENT_ID of the base class without loading sub-class in Spring boot JPA
For example we have a base model:
@Entity
@Table(name = "TM_POSITIONS")
public class PositionEntity {
@Id
@SequenceGenerator(name = "PositionsSequence", sequenceName = "TM_POSITIONS_SEQ", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PositionsSequence")
private long id;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
@JoinColumn(name = "DEPARTMENT_ID")
private DepartmentModel department;
...
So, how to just get DEPARTMENT_ID without bundle it and load another object. In some cases, I need to get related Model and in some cases, I need to get just DEPARTMENT_ID.