Beginner |
|
Joined: Tue Nov 18, 2003 12:34 am Posts: 39 Location: Dallas, Texas, US
|
I think I should make it more clear. I understand that in order to have a single quote in name I should add another single quote (escape character) to preserve the actual single quote and that is what the processSingleQuote() method does. So, my in query it would look like
-> where name = '''test'''
The only point that I missed is that I create another object with one of its member like this.
-> obj.name = ''test''
as I believe that the db would require the escape character to preserve the single quote in name.
I then save the object obj. Now, in another session I load the same object and notice that it contains
-> obj.name = ''test''
and NOT
-> obj.name = 'test' . I was actually expecting only 'test' since the escape character should be 'escaped' while saving and it was not happening.
Anyway, I solved it just by doing this while ASSINGNING
-> obj.name = 'name' as I found that during update the extra, escape single quote wasn't necessary during save/update.
I was only curious why an escape character was required during "find" and not required later in member assignment or "save". Perhaps Hibernate is smart enough to add escape characters (while doing an insert) with an understanding that the programmer might have forgotten to do so. I hope now it is clear.
Thanks,
Madhan.
|
|