-->
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: ColumnTransformer causes table scans
PostPosted: Tue Aug 02, 2011 8:56 pm 
Newbie

Joined: Tue Aug 02, 2011 8:12 pm
Posts: 1
We've been looking into the ColumnTransformer to encrypt certain parts of our data. It seemed like a great fit and the JavaDoc indicated that it would work in queries as well as read write operations.

And it does all of that, but the application of the transformer if the column is referenced in a where clause is resulting in a table scan.

So if I have a column I want to protect called secret and I've annotated it
Code:
    @ColumnTransformer(read = "AES_DECRYPT(UNHEX(secret), 'password')", write = "HEX(AES_ENCRYPT(?, 'password'))")
    private String secret;


Hibernate will generate the following:
Code:
where AES_DECRYPT(UNHEX(webuser0_.secret), 'password')=?


which results in a table scan.

What would be better would be if the generated sql looked like this:
Code:
where webuser0_.secret=HEX(AES_ENCRYPT(?, 'password'))


Which results in a query that uses an index and calculates the encryption only once.

So is there a way to get the transformer to behave differently and generate a more sensible where clause?


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.