Issue
I have to do some improvements to a legacy project using Hibernate 5.0.9 with Oracle database. I noticed that hibernate are generating queries like that
select a.id, b.id
from a, b
where a.b_id = b.id(+)
instead of
select a.id, b.id
from a left join b on a.b_id = b.id
for a code like this
Criteria criteria = session.createCriteria(A.class, "a");
criteria.createAlias("a.b", "b", JoinType.LEFT_OUTER_JOIN);
criteria = criteria.setProjection(
Projections.projectionList()
.add(Projections.property("a.id"))
.add(Projections.property("b.id"))
);
criteria.list();
At least for me, the "(+)" is complicated to read. In other project with same Hibernate version, the "joins" are generated normally.
Is this a Hibernate configuration?
Solution
Following the suggestion, adding the dialect information in persistence.xml solved the problem.
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect" />
Answered By - jks1903
Answer Checked By - David Goodson (JavaFixing Volunteer)