Date: Thu, 08 Sep 2011 09:48:36 +0200 From: Lele User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 Newsgroups: comp.lang.java.help Subject: Re: CriteriaQuery and JPA References: <4e676e7b$1@news.x-privat.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: $$afwhll$slnyo.news.x-privat.org Message-ID: <4e687355$2@news.x-privat.org> Organization: X-Privat.Org NNTP Server - http://www.x-privat.org Lines: 26 X-Authenticated-User: $$p9zou1n1$ng5dhdq$s2 X-Complaints-To: abuse@x-privat.org Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!news2.euro.net!newsfeed.x-privat.org!x-privat.org!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:1023 Il 07/09/2011 20:02, Lew ha scritto: > Read the Javadocs for 'Root#get(String attributeName)'. You gave a 'null' attribute name, and what you tried to do wasn't giving an attribute *name*, but an attribute *value*. Ok, I try to remake my question. My class has a field named 'username': public MyClass{ public String username; } I have to create a where clause that check if this field is equal to a constant value: WHERE username = "test" I understand that Root#get(String attributeName) give to me the attribute name (and not the attribute value), so how can i put a constant value inside the clause? filter.where(criteriaBuilder.equal(from.get("username"),"test")); with this code i would expect a where clause like the above. Instead i have the null value : WHERE username = ? Sorry but I'm new to JPA