You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since 3.1.1, the following entity / query is not working anymore:
@Entity
@Table
public class TestEntity {
@Id
@Column(name = "ID")
private Long id;
@NotNull
@Column(name = "TEST_TYPE", nullable = false)
private String type;
}
}
@Query(value = "select te from TestEntity te where te.type = :type")
List<TestEntity> findByType(@Param("type") String type);
Result: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: Line 1:34 no viable alternative at input 'te.type'; Bad JPQL grammar
Seems related to #2791 but I cannot make it work.
I'm not using Hibernate but eclipselink with h2.
What I've tried (all not working):
@Query(value = "select te from TestEntity te where te.`type` = :type")
List<TestEntity> findByType(@Param("type") String type);
@Query(value = "select te from TestEntity te where te.\"type\" = :type")
List<TestEntity> findByType(@Param("type") String type);
@Query(value = "select te from TestEntity te where te.type = :testType")
List<TestEntity> findByType(@Param("testType") String type);
@Query(value = "select te from TestEntity te where te.type2 = :type")
List<TestEntity> findByType(@Param("type") String type);
The only way to make it work is by renaming BOTH entity field and query param:
@Query(value = "select te from TestEntity te where te.type2 = :testType")
List<TestEntity> findByType(@Param("testType") String type);
Or to not use JPQL (but that's not the goal):
List<TestEntity> findByType(String type);
Thanks,
The text was updated successfully, but these errors were encountered:
@gregturn , Good Day.
Recently we encountered a similar problem, but for the lateral keyword, when it is an entity field and need to build a jpql query.
We encountered this issue while migrating from Spring Boot 3.0 to Spring Boot 3.1 (spring-data-jpa 3.1.*)
Hello,
Since 3.1.1, the following entity / query is not working anymore:
Result: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: Line 1:34 no viable alternative at input 'te.type'; Bad JPQL grammar
Seems related to #2791 but I cannot make it work.
I'm not using Hibernate but eclipselink with h2.
What I've tried (all not working):
The only way to make it work is by renaming BOTH entity field and query param:
Or to not use JPQL (but that's not the goal):
Thanks,
The text was updated successfully, but these errors were encountered: