Hi!
I am using hibernate core 6.0.0.Alpha6, and mysql-connector 8.0.22. DB MySql org.hibernate.dialect.MySQLDialect. My problem occurs on previous release too.
Running a simple SQL query on a single table, no join, returns only last record for n times, where n is the correct records number.
HQL Query
SELECT ig.id, ig.codice
FROM ImpiantiGestitiDto as ig
where ig.idPalestra='6' order by ig.id";
Schema: id=integer idPalestra=integer codice=varchar(6) ImpiantiGestitiDto=Dto
This is my code. I don’t use loop.
Query<Object> query = session.createQuery(hql);
result = query.getResultList();
The mysql-connector run the query succesfully:
Output on getResultList(); Wrong!
[[10,“000.03”],[10,“000.03”],[10,“000.03”],[10,“000.03”]]
I think the problem occurs in: -org.hibernate.sql.results.spi package; -class ListResultsConsumer; -method Consume.
in following loop, results.add(row)
; instructions occurs the error. Why occurs the problem? Can you help me? Thank you!
while (rowProcessingState.next()) {
final R row = rowReader.readRow( rowProcessingState, processingOptions );
boolean add = true;
if ( uniqueRows ) {
if ( results.contains( row ) ) {
add = false;
}
}
if ( add ) {
results.add( row );
}
rowProcessingState.finishRowProcessing();
}
Using the query “FROM ImpiantiGestitiDto where idPalestra=‘6’ order by id” it’s works.
Using the query “SELECT id, codice FROM ImpiantiGestitiDto where idPalestra=‘6’ order by id” does not work.
I have to use the second query because the table ImpiantiGestitiDto is joined to another table and I have to use the WHERE clause.
Thanks for your answer.