That answer you’re referring to is from 2021 and was targeting Hibernate ORM 5. You’re asking about Hibernate ORM 6 here and I gave you an answer, but I’ll repeat it once more for you.
There is no direct replacement for hydrate, because the whole process of how data is read from JDBC and built into objects changed fundamentally.
If you don’t want to introduce transient fields in your entities, you can use an embeddable type to wrap the encrypted data e.g.
@Embeddable
public class EncryptedString {
private String encryptedData;
@Column(insertable = false, updatable = false)
private String key;
private transient String plainData;
@PostLoad
void init() {
this.plainData = decrypt(encryptedData, key);
}
public void setPlainData(String data) {
this.plainData = data;
this.encryptedData = encrypt(data, key);
}
}