如果该策略占据一席之地,Hib 会忽略 id 设置。
有什么方法可以避免这种情况并保存策略吗?
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
public Long getId() {
return id;
}
...
Account account = new Account();
account.setId(1000L);
account.setSmth(smth);
...
//Tried to do so, but tomcat hangs on this string.
session.createSQLQuery("ALTER TABLE account AUTO_INCREMENT = " + account.getId() + ";").executeUpdate();
session.save(account);
...
斯帕西博!