I am using Hibernate read/write properties to decrypt and encrypt data while reading and writing. I am able to read the values but I am unable to write data into DB.
My configuration would be something like below, followed by the exception stacktrace that is noticed
Code:
<property name="dataIdentifier" type="string">
<column name="DATA_IDENTIFIER"
read="RTRIM(DECODE(DATA_IDENTIFIER,NULL,NULL,FN_DECRYPT(DATA_IDENTIFIER, ID)))"
write="RTRIM(DECODE(DATA_IDENTIFIER,NULL,NULL,FN_ENCRYPT(DATA_IDENTIFIER, ID)))"/>
</property>
Code:
Caused by: org.hibernate.MappingException: write expression must contain exactly one value placeholder ('?') character
at org.hibernate.cfg.HbmBinder.bindColumn(HbmBinder.java:1784)
at org.hibernate.cfg.HbmBinder.bindColumns(HbmBinder.java:1094)
at org.hibernate.cfg.HbmBinder.bindColumnsOrFormula(HbmBinder.java:1628)
at org.hibernate.cfg.HbmBinder.bindSimpleValue(HbmBinder.java:1208)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2206)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2164)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:412)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:326)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:177)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4006)
From the exception, I understand that the 'write' property in my configuration has three placeholders as opposed to one which could be causing this issue. If we can use multiple placeholders in 'read' property, not sure why 'write' property is been restricted to handle only one placeholder!
I am using Hibernate-3.6.5 with Spring 3.0.6. Please do let me know if anyone has a workaround for this issue so that I can use multiple placeholders while writing into DB.
Thanks.