H2 SQLGrammarException:无法准备语句
H2 SQLGrammarException: could not prepare statement
我有一个 spring 引导应用程序,它带有一个由 UserRepository 寻址的 h2 数据库。我正在尝试使用 Spring 安全性来使用 jdbc(此处休眠)
进行身份验证
@Entity
@Table(name="USER")
public class User {
@Id
@Column(name="USER_ID")
private long id;
@Column(name="USERNAME, nullable = false, unique = true")
private String username;
@Column(name="PASSWORD")
private String password;
/*setter/getter follows */
}
存储库:-
public interface UserRepository extends JpaRepository<User, Long>{
User findByUsername(String username);
}
SQL:
CREATE TABLE USER(
USER_ID BIGINT AUTO_INCREMENT PRIMARY KEY,
USERNAME VARCHAR(128) NOT NULL UNIQUE,
PASSWORD VARCHAR(256) NOT NULL
);
插入用户(用户名,密码)值('jdoe','foobar');
But when enter correct username and password, it is not accepting it.
Exception:
SQL Error: 42001, SQLState: 42001
2022-03-04 13:43:18.571 ERROR 17924 --- [nio-8080-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper : Syntax error in SQL statement "SELECT USER0_.USER_ID AS USER_ID1_0_, USER0_.PASSWORD AS PASSWORD2_0_, USER0_.USERNAME, NULLABLE = FALSE, UNIQUE[*] = TRUE AS USERNAME3_0_ FROM USER USER0_ WHERE USER0_.USERNAME, NULLABLE = FALSE, UNIQUE = TRUE=? "; expected "*, NOT, EXISTS, INTERSECTS, SELECT, FROM, WITH"; SQL statement:
select user0_.user_id as user_id1_0_, user0_.password as password2_0_, user0_.username, nullable = false, unique = true as username3_0_ from user user0_ where user0_.username, nullable = false, unique = true=? [42001-196]
不错的错误:
@Column(name="USERNAME, nullable = false, unique = true")
->
@Column(name="USERNAME", nullable = false, unique = true)
我有一个 spring 引导应用程序,它带有一个由 UserRepository 寻址的 h2 数据库。我正在尝试使用 Spring 安全性来使用 jdbc(此处休眠)
进行身份验证@Entity
@Table(name="USER")
public class User {
@Id
@Column(name="USER_ID")
private long id;
@Column(name="USERNAME, nullable = false, unique = true")
private String username;
@Column(name="PASSWORD")
private String password;
/*setter/getter follows */
}
存储库:-
public interface UserRepository extends JpaRepository<User, Long>{
User findByUsername(String username);
}
SQL:
CREATE TABLE USER(
USER_ID BIGINT AUTO_INCREMENT PRIMARY KEY,
USERNAME VARCHAR(128) NOT NULL UNIQUE,
PASSWORD VARCHAR(256) NOT NULL
);
插入用户(用户名,密码)值('jdoe','foobar');
But when enter correct username and password, it is not accepting it.
Exception:
SQL Error: 42001, SQLState: 42001
2022-03-04 13:43:18.571 ERROR 17924 --- [nio-8080-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper : Syntax error in SQL statement "SELECT USER0_.USER_ID AS USER_ID1_0_, USER0_.PASSWORD AS PASSWORD2_0_, USER0_.USERNAME, NULLABLE = FALSE, UNIQUE[*] = TRUE AS USERNAME3_0_ FROM USER USER0_ WHERE USER0_.USERNAME, NULLABLE = FALSE, UNIQUE = TRUE=? "; expected "*, NOT, EXISTS, INTERSECTS, SELECT, FROM, WITH"; SQL statement:
select user0_.user_id as user_id1_0_, user0_.password as password2_0_, user0_.username, nullable = false, unique = true as username3_0_ from user user0_ where user0_.username, nullable = false, unique = true=? [42001-196]
不错的错误:
@Column(name="USERNAME, nullable = false, unique = true")
->
@Column(name="USERNAME", nullable = false, unique = true)