fix a bug in @Query handling

add a test for empty query string in @Query

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-03-28 23:01:48 +01:00 committed by Christian Beikov
parent 39f09aecae
commit e829a01aee
2 changed files with 7 additions and 2 deletions

View File

@ -1,8 +1,13 @@
package org.hibernate.processor.test.data.eg;
import jakarta.data.repository.BasicRepository;
import jakarta.data.repository.Query;
import jakarta.data.repository.Repository;
import java.util.stream.Stream;
@Repository
public interface Publishers extends BasicRepository<Publisher,Long> {
@Query(" ")
Stream<Publisher> all();
}

View File

@ -75,7 +75,7 @@ import static org.hibernate.grammars.hql.HqlLexer.HAVING;
import static org.hibernate.grammars.hql.HqlLexer.IDENTIFIER;
import static org.hibernate.grammars.hql.HqlLexer.ORDER;
import static org.hibernate.grammars.hql.HqlLexer.WHERE;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.qualify;
import static org.hibernate.processor.annotation.AbstractQueryMethod.isSessionParameter;
import static org.hibernate.processor.annotation.AbstractQueryMethod.isSpecialParam;
@ -2143,7 +2143,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
throw new AssertionFailure("@Entity annotation should not be missing");
}
final String name = (String) getAnnotationValue(annotation, "name");
return isNotEmpty(name) ? resultType.asElement().getSimpleName().toString() : name;
return isEmpty(name) ? resultType.asElement().getSimpleName().toString() : name;
}
else if ( primaryEntity != null ) {
return primaryEntity.getSimpleName().toString();