Hi,
I'm using hibernate and acegi.My user class has a method to get password but the value of the password is depend on another field value in the same class.The class looks like below (only the relevant code is stated below)
@Entity
@Table(name="user")
public class User implements Serializable, UserDetails {
protected String password;
protected UserInfo userInfo;
@Column(name="password",length=255)
public String getPassword() {
if (null !=getLoginType() && getLoginType().equals("pin"))
return getUserInfo().getFirstName();
return password;
}
@Column(name="login_type",nullable=true,length=3)
public String getLoginType() {
return loginType;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="user_info_id",nullable=false)
public UserInfo getUserInfo() {
if (userInfo == null){
userInfo = new UserInfo();
}
return userInfo;
}
My question is can I implement the getPassword() as above? Is it valid way of doing?
Appreciate any suggestions.
Thanks


Reply With Quote

