Account class:
@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;
}
...
if i try to do that:
temp = new Account();
temp.setAccountId(tempId); //
session.save(temp);
System.out.println("accountid...." + temp.getAccountId());
it prints an accountId which is not equal to tempId, i think its because it is a auto-increment field in the table
on the other hand if i do that:
temp = new Account();
session.save(temp);
temp.setAccountId(tempId);
session.merge(temp);
i get exception:
org.hibernate.HibernateException: identifier of an instance
of ... was altered from 1244 to 1221
how can i override the id?