A situation may arise in which:
-- a reverse-engineered model is being extended, and re-definition of columns is not allowed
and
-- Hibernate annotations are being used instead of configuration files
Here is how the encryption type can be defined through annotation at the package level so that it can be used in all entities, whether auto-generated or extended:
@org.hibernate.annotations.TypeDefs(
{
@org.hibernate.annotations.TypeDef(
name="encryptedString",
typeClass=org.jasypt.hibernate.type.EncryptedStringType.class,
parameters= {
@org.hibernate.annotations.Parameter(name="encryptorRegisteredName", value="hibernateStringEncryptor")
}
)
}
)
package com.findax.model;
package-info.java:
@org.hibernate.annotations.TypeDefs(
{
@org.hibernate.annotations.TypeDef(
name="encryptedString",
typeClass=org.jasypt.hibernate.type.EncryptedStringType.class,
parameters= {
@org.hibernate.annotations.Parameter(name="encryptorRegisteredName", value="hibernateStringEncryptor")
}
)
}
)
package com.example.model;