I am trying to run such JPQL query:
SELECT t1 FROM Table1 t1 ORDER BY t1.column1.id ASC
Column1 as such implementation:
// bi-directional many-to-one association to Table1
@ManyToOne(fetch = FetchType.LAZY)
@Joi开发者_StackOverflow社区nColumn(name = "idTable1Parent")
private table1 column1;
Table1 column idTable1Parent is a FK to the Table1 column id PK.
Some records have idTable1Parent as NULL.
The problem is when I ORDER BY ASC the values, the records that have idTable1Parent are not returned, and I need that records.
Do you have some tips or solution so I can get the records that have idTable1Parent as null?
Thanks in advance.
You need to use an outer join,
SELECT t1 FROM Table1 t1 left join t1.column1 c1 ORDER BY c1.id ASC
精彩评论