You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by zhourui <zh...@zoneland.net> on 2015/01/01 05:33:45 UTC

how to query list property with criteria query?

have entity like:
@Entity
public class CompanyAttribute extends SliceJpaObject {
	@PersistentCollection(fetch = FetchType.EAGER)
	private List<String> attributeList = new ArrayList<String>();
	......
}

now need to select the List property 'attributeList' only in criteria query,
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<List&lt;String>> cq = cb.createQuery(List<String>.class);

CriteriaQuery<List&lt;String>> cq = cb.createQuery(List<String>.class); is
mistake.
hoe to do it.

thanks!



--
View this message in context: http://openjpa.208410.n2.nabble.com/how-to-query-list-property-with-criteria-query-tp7587532.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: how to query list property with criteria query?

Posted by zhourui <zh...@zoneland.net>.
<http://openjpa.208410.n2.nabble.com/file/n7587534/error.png> 

it's seems not right!

The method select(Selection<? extends String>) in the type
CriteriaQuery<String> is not applicable for the arguments
(Expression<List&lt;String>>)



--
View this message in context: http://openjpa.208410.n2.nabble.com/how-to-query-list-property-with-criteria-query-tp7587532p7587534.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: how to query list property with criteria query?

Posted by José Luis Cetina <ma...@gmail.com>.
Just

CriteriaQuery<String> cq = cb.createQuery(String.class);

And then:

List<String> lst = em.createQuery(cq).getResultList();

El mié, 31 de diciembre de 2014 22:34, zhourui <zh...@zoneland.net>
escribió:

> have entity like:
> @Entity
> public class CompanyAttribute extends SliceJpaObject {
>         @PersistentCollection(fetch = FetchType.EAGER)
>         private List<String> attributeList = new ArrayList<String>();
>         ......
> }
>
> now need to select the List property 'attributeList' only in criteria
> query,
> CriteriaBuilder cb = em.getCriteriaBuilder();
> CriteriaQuery<List&lt;String>> cq = cb.createQuery(List<String>.class);
>
> CriteriaQuery<List&lt;String>> cq = cb.createQuery(List<String>.class); is
> mistake.
> hoe to do it.
>
> thanks!
>
>
>
> --
> View this message in context: http://openjpa.208410.n2.
> nabble.com/how-to-query-list-property-with-criteria-query-tp7587532.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>