我有一个具有Id列的实体,如下所示
$qry = "SELECT * FROM members WHERE CHAR_LENGTH(names) > 5 AND CHAR_LENGTH(names) < 10"
liquibase配置在h2中设置架构如下
@Entity
@Table(schema = "vw")
public class School {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
准备好的语句作为TriggerAdapter的一部分,以便写入视图。
公共类UpdatableViewSchool扩展了TriggerAdapter { private PreparedStatement prepDelete,prepInsert;
CREATE TABLE school
(
id BIGINT IDENTITY (1, 1),
我收到错误
@Override
public void init(Connection conn, String schemaName, String triggerName,
String tableName, boolean before, int type) throws SQLException {
prepDelete = conn.prepareStatement("DELETE FROM school WHERE id = ?");
prepInsert = conn.prepareStatement("INSERT INTO school " +
" (school, class, first, second, third, fourth, " +
" fifth, sixth, seventh, eighth, ninth, tenth ) " +
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?)");
super.init(conn, schemaName, triggerName, tableName, before, type);
}
@Override
public void fire(Connection conn, ResultSet oldRow, ResultSet newRow)
throws SQLException {
if (oldRow != null && oldRow.next()) {
prepDelete.setInt(1, oldRow.getInt(1));
prepDelete.execute();
}
if (newRow != null && newRow.next()) {
prepInsert.setInt(1, newRow.getInt(2)); // school
prepInsert.setString(2, newRow.getString(4)); // class
prepInsert.setInt(3, newRow.getInt(5)); // first
h2中的IDENTITY列不应该是自动递增列吗?