我的堆栈跟踪
java.sql.SQLSyntaxErrorException: Unknown column 'i' in 'field list'
5分钟后我的堆栈跟踪是
Named parameter lastName not bound
此查询中的问题是什么?
我的界面
public interface InstructorDao extends JpaRepository <Instructor, Long> {
@Query (nativeQuery=true, value ="select i from Instructor as i where i.firstName like %:firstName% or i.lastName like %:firstName%")
List <Instructor> findInstructorByfirstName (@Param ("firstName") String firstName);
我的实体
@Entity
@Table (name = "Instructor")
public class Instructor {
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Column (name = "instructor_id", nullable = false)
private Long instructorId;
@Basic
@Column (name = "name", nullable = false, length = 45)
private String firstName;
@Basic
@Column (name = "lastName", nullable = false, length = 45)
private String lastName;
@Basic
@Column (name = "summary", nullable = false, length = 45)
private String instructorSummary;
@OneToMany (mappedBy = "instructor", fetch = FetchType.LAZY)
private Set <Course> courses = new HashSet<>(); 'i' in 'field lis
另外,如果有人知道我在哪里可以找到关于不同SQL语言的所有资料,我将非常感激,因为有时专业人士会编写
select i from Instructor as i where i.firstName like %:firstName% or i.lastName like %:firstName% or
select i from Instructor as i where i.user.userEmail =:userEmail or
select * from courses as c where c.course_id in (select e.course_id from enrolled_in as e where e.student_id = :studentId)
我必须知道所有的密码!
1条答案
按热度按时间fcg9iug31#
由于您将查询指定为原生查询,因此必须使用
*
来全选。或