-->
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: JPA CriteriaBuilder - Expression <List>
PostPosted: Tue Jun 24, 2014 7:01 pm 
Newbie

Joined: Wed Oct 16, 2013 8:53 am
Posts: 3
I have a simple CriteriaQuery where I pattern match a simple search String against field entires in a Person entity... e.g the searchString is always decorated with
Code:
%searchString%


Code:
//using MetaModel
Expression<List<Records>> records = root.get(Person_.records);
Expression<String> param = builder.parameter(String.class);

//pseudo code(i think i need something like this here)
Predicate myPred = for all records (any record.FIELD LIKE searchString)

Path<Integer> status = root.get("status");

criteriaQuery.where(
    builder.or(
        builder.like(
            root.<String>get("name"), searchString
        ),
        builder.like(
            root.<String>get("second_name"), searchString
        )
        //pseuso code (i thin i need to check my predicate here?)
        builder.like(mypredicate)



    ),
    builder.equal(status,value)
);


The Person object can contain many Record objects. I would like to update my query above to include a similar 'like' pattern match for each applicable field(String) of each element of the List of Records. I obtain the Records like below:

Code:
//using MetaModel
Expression<List<Records>> records = root.get(Person_.records);
Expression<String> param = builder.parameter(String.class);


Any help much appreciated.


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.