-->
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: Explicit SQL or HQL in CriteriaQuery possible?
PostPosted: Mon Apr 02, 2012 1:37 pm 
Newbie

Joined: Fri Mar 30, 2012 12:38 pm
Posts: 1
Here's the situation.

I have a complicated query built using CriteriaBuilder that I don't want to throw away.
I have a field in one of my entities that uses a custom type def (it's an encrypted string).
When I query against that field it runs the parameter I pass through the custom type serializer and uses that to query against the DB.

Code:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
Root<Entity> from = cb.from(Entity.class);
Predicate p = cb.equal(from.get("someField"), "someValue");


Normally this would be great, but in my case this is not the behaviour I want. I would like to bypass the serialization of the parameter. Is there any way to do that in a CriteriaQuery? Can I somehow query using SQL explicitly or get the entityManager to temporarily treat the field as a plain string rather than the custom type I've defined it to be?

Why don't I want the default behaviour? Because the when I serialize the field I add a string indicating the encryption strategy used directly to the field. So as long as the encryption strategy never changes then my query will have no problem However, if the encryption strategy changes then I need to be able to query against all possible encryption formats used.

An example serialized string might be (using JSON): "{"strategy":"strategy1","data":"nsadkWXc?*"}"


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.