アカウント クラス:
@Entity
@Table(name = "Account")
public class Account {
...
private String accountId;
...
@Id
@GeneratedValue
@Column(name = "accountId")
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
...
私がそれをしようとすると:
temp = new Account();
temp.setAccountId(tempId); //
session.save(temp);
System.out.println("accountid...." + temp.getAccountId());
tempIdと等しくないaccountIdを出力します。これは、テーブルの自動インクリメントフィールドであるためだと思います
一方、私がそれを行う場合:
temp = new Account();
session.save(temp);
temp.setAccountId(tempId);
session.merge(temp);
私は例外を取得します:
org.hibernate.HibernateException: identifier of an instance
of ... was altered from 1244 to 1221
どうすればIDを上書きできますか?