如何解密hibernate上的密码

时间:2016-04-22 06:21:02

标签: java spring hibernate encryption hql

我想将数据库中的字段解密为字符串,我想在spring上将其传递给控制器​​。我有一个像这样的hibernate类:

@Id
@Column(name = "USER_ID")

private BigDecimal userId;

@Column(name = "user_name")
private String username;

@Column(name = "EMPLOYEE_ID")
private BigDecimal employeeId;

@Column(name = "encrypted_user_password")
@ColumnTransformer( write="EncryptByPassPhrase('BN1HC1T',?)", read="decrypt ('BN1HC1T',pswd)" )
private String encrypted_user_password;

public BigDecimal getUserId() {
    return userId;
}

public void setUserId(BigDecimal userId) {
    this.userId = userId;
}

public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

public BigDecimal getEmployeeId() {
    return employeeId;
}

public void setEmployeeId(BigDecimal employeeId) {
    this.employeeId = employeeId;
}

public String getEncrypted_user_password() {
    return encrypted_user_password;
}

public void setEncrypted_user_password(String encrypted_user_password) {
    this.encrypted_user_password = encrypted_user_password;
}

查询的结果是:

select
    karyawan0_.USER_ID as USER_ID1_0_,
    karyawan0_.EMPLOYEE_ID as EMPLOYEE_ID2_0_,
    decrypt('BN1HC1T',
    karyawan0_.encrypted_user_password) as encrypted_user_pas3_0_,
    karyawan0_.user_name as user_name4_0_ 
from
    FND_USER karyawan0_ 
where
    karyawan0_.user_name=?

我得到这样的错误:

java.sql.SQLSyntaxErrorException: ORA-00904: "DECRYPT": invalid identifier

我的问题是对的,但我收到了错误。如何解决?

1 个答案:

答案 0 :(得分:0)

返回错误ORA-00904,因为对象(在这种情况下为函数decrypt(?,?))不存在或者DB帐户没有适当的权限来访问它。