FEATURE: HibernateSQLQuery.*join parity with HibernateQuery.*join #2077

Open
johnjaylward opened this Issue Jan 5, 2017 · 2 comments

Projects

None yet

1 participant

@johnjaylward
johnjaylward commented Jan 5, 2017 edited

I was trying to switch a query from HibernateQuery to HibernateSqlQuery but hit a snag when trying to switch the join paths over. My current HibernateQuery hooks into both a CollectionPath and a MapPath on my object. However, the HibernateSqlQuery does not have similar functions for linking into these paths.

QEntity qe = QEntity.entity;
QEntityMap qem = QEntityMap.entityMap;
QEntityCollection qec = QEntityMap.entityCollection;

HibernateQuery hq = new HibernateQuery(...).from(qe);
hq.innerJoin(qe.mapPath,qem);
hq.leftJoin(qe.collectionPath,qec);
hq.where(qec.isNull().or(qec.someValue.equals("someValue")));
hq.select(qem.anotherValue);

I can't seem to find a way to do this with a HibernateSQLQuery since the generated entities don't have foreign keys.

I'd like the option of using both HQL and native SQL in the same project, but maybe that's not possible?

Do I need to kill my hibernate/jpa generations and only use native SQL generations?

@johnjaylward

The main reason I'd like to continue to use HQL and SQL is because I also use the HibernateDeleteClause and HibernateUpdateClause classes. Would I need to replace these as well? If so, how could I go about doing that efficiently?

@johnjaylward

ok, I see some instructions here http://www.querydsl.com/static/querydsl/4.1.3/reference/html/ch02.html#d0e431

However, I'm not sure what the Maven is doing. I'm using gradle, and I'm not sure I understand enough of that maven portion to write my own gradle task.

I do see that there is an Ant task AntMetaDataExporter which looks like it takes similar arguments to the Maven plugin that I should be able to use from gradle. However, I'm not sure what the important pieces of configuration are. Do I need to use Darby, or should I use my actual development database (MySQL in this case)? It also looks like I need to change the namePrefix setting to "S" to match the query samples, but that's not in the example Maven configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment