如果该策略占据一席之地,Hib只是忽略一个id设置。休眠:在案例中插入一个具有自定义ID的实体:strategy = GenerationType.AUTO
有什么办法可以避免这种情况并保存策略?
@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);
...
Spasibo!