I have a entity called Test.java with 70 fields, some of the fields are related to other entities also(through join one to many, many to one, etc assosiations).
I need to have an object of this type but I don't need all the fields just 3 fields out of them one field has foreign key relation relation with other entity.
So, I wrote a native query while executing the query jpa executing other queries also causes taking so much time to complete.
Here is my entity class:
public Class Test implements Serializable{
@Id
private int id;
@ManyToOne
@JoinColumn(name = "STATUSID")
private xxxxx xxxxx;
/// other fields, getters and setters
}
Here is my native query
public List<Order> getAllOpenOrders() {
final String query = "SELECT t.* from T_TEST";
Query createNativeQuery = em.createNativeQuery(query, Test.class);
List<Order> resultList = createNativeQuery.getResultList();
return resultList;
}
How can I get the Order entity object with selected fields, I don't need other fields means I am using only these three fields for my functionlity.
How can I stop other queries execution?
Thank you.