记录一次报错。
java.sql.SQLSyntaxErrorException: Unknown column 'subwaycoun0_.pass_num1' in 'field list'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.18.jar:8.0.18]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.18.jar:8.0.18]
记录一次报错。
在数据库查询中,对实体类使用JpaRepository,如用户表
-- 用户表
CREATE TABLE IF NOT EXISTS USER
(id INT UNSIGNED AUTO_INCREMENT,
userName VARCHAR(20) NOT NULL,
passWord VARCHAR(32) NOT NULL,
sex VARCHAR(4) NOT NULL,
phone VARCHAR(32),
email VARCHAR(32),
employer VARCHAR(32),
remarks VARCHAR(1000),
PRIMARY KEY (id)
)ENGINE=INNODB DEFAULT CHARSET=utf8;
//user类
public class User {
@Id
@Column
private String id;
@Column
private String userName;
@Column
private String passWord;
@Column
private String sex;
@Column
private String phone;
@Column
private String email;
@Column
private String employer;
@Column
private String remarks;
。。。。
}
//数据库交互类
import com.example.springboot.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface UserMapper extends JpaRepository<User,String> {
User findUserByUsername(String username);
Page<User> findAll(Pageable pageable);
List<User> findAll();
}
此时在调用查找时会报错如下:
java.sql.SQLSyntaxErrorException: Unknown column 'subwaycoun0_.pass_num1' in 'field list'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.18.jar:8.0.18]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.18.jar:8.0.18]