I thin'k to use my business key in this way but don't work
hibernate don't insert and don't update where are i wrong?
Pls help me
Devis
Code:
CREATE TABLE user (
id integer NOT NULL, -- values generated from user_id_seq
email varchar(128) NOT NULL,
passwd varchar(128) NOT NULL
);
CREATE SEQUENCE user_id_seq;
public class User {
private Long id;
private String email;
private String password;
public Long getId() { return id; }
@SuppressWarnings("unused")
private void setId(Long i) { id = i; }
public String getEmail() { return email; }
public void setEmail(String e) { email = e; }
public String getPassword() { return password; }
public void setPassword(String p) { password = p; }
public int hashCode() {
return email.hashCode();
}
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof User)) return false;
final User that = (User) obj;
return email.equals(that.getEmail());
}
}
<hibernate-mapping>
−
<class name="User" table="user">
−
<id name="id">
−
<generator class="sequence">
<param name="sequence">user_id_seq</param>
</generator>
</id>
<property name="email"/>
<property name="password" column="passwd"/>
</class>
</hibernate-mapping>
Dao Class
TblUtentiDAO ex = new TblUtentiDAO();
User vo = new User()
vo.setEmail("mario@italia.it");
vo.setDescr("ciao");
ex.SaveOrUpdate(vo);
ex.getSession().Close();