I\'ve got a bit of a bizarre problem that I can\'t figure out why it\'s happening. I\'m sure I did something wrong, because this is my first time using a data projection and I\'
I had the same problem and i solved by odering the query columns alphabetically.
In you case:
public interface OrderTrackingRepository extends JpaRepository {
@Query( nativeQuery = true,
value = "SELECT a.accountnumber, o.date_of_order, t.tracking_id " +
"FROM account as a " +
"INNER JOIN orders as o USING (account_id) " +
"INNER JOIN tracking as t USING (tracking_id) " +
"WHERE a.accountnumber = :acctnum")
Collection findOrderInfoForAccount(@Param("acctnum") acctNumber, Class type);
}
So you will get:
getAccountNumber() -> accountnumber getDateOfOrder() -> date_of_order getTrackingId() -> tracking_id