Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Hibernate搜索按字段值获取行_Mysql_Spring_Hibernate_Jakarta Ee_Web Applications - Fatal编程技术网

Mysql Hibernate搜索按字段值获取行

Mysql Hibernate搜索按字段值获取行,mysql,spring,hibernate,jakarta-ee,web-applications,Mysql,Spring,Hibernate,Jakarta Ee,Web Applications,我不熟悉冬眠和春天 我的学生班有: studentId; firstName; lastName; yearLevel; getters/setters ...etc 我想按学生的名字或姓氏搜索。 所以我在StudentDaoImpl.java中尝试了这个方法: @Override public Student getStudentByLastName(String lastName) { return (Student)session.getIdentifier(las

我不熟悉冬眠和春天

我的学生班有:

studentId;  
firstName;  
lastName;   
yearLevel;
getters/setters
...etc
我想按学生的名字或姓氏搜索。 所以我在StudentDaoImpl.java中尝试了这个方法:

@Override
public Student getStudentByLastName(String lastName) {
    return (Student)session.getIdentifier(lastName);
}  
而且它不起作用唯一起作用的是studentId搜索:

public Student getStudentByLastName(int studentId) {

    return (Student)sessionFactory.getCurrentSession().get(Student.class,studentId);
}

有没有办法通过搜索字段值(如lastName或firstName)来获取学生对象

我认为在命名变量时应该使用camelCase(firstName而不是firstName等)。

Bean命名约定

例如,约定是使用标准Java约定 命名bean时的字段名。也就是说,bean名称以 小写字母,从那时起用驼色大写。这方面的例子 名称应为(不带引号)“accountManager”、“accountService”, “userDao”、“loginController”等等

一致地命名bean可以使您的配置更易于阅读和修改 理解,如果您正在使用SpringAOP,当 将建议应用于一组按名称相关的bean