I'm getting a weird result in session.save(). It is always returning 1. but the value in database is inserted correctly. Please suggest anything you found doubtful
Code
session = getSessionFactory().openSession();
Transaction transaction = session.beginTransaction();
userId = (Long)session.save(user);
transaction.commit();
User - Persistence
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@GenericGenerator(name = "increment", strategy = "increment")
@Column(name = "ID")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name = "USERNAME", length = 100)
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "PASSWORD", length = 100)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@OneToOne(fetch = FetchType.EAGER)
@MapsId
@JoinColumn(name = "ROLEID")
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
@Column(name = "IMAGEURL", length = 2000)
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
Version
Hibernate: 4.3.7 final
Spring: 4.1.2