-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: MappingException: write expression must contain exactly one
PostPosted: Thu Nov 17, 2011 9:03 am 
Newbie

Joined: Thu Nov 17, 2011 8:48 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.