Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1023

Re: CriteriaQuery and JPA

Date 2011-09-08 09:48 +0200
From Lele <lele@lele.com>
Newsgroups comp.lang.java.help
Subject Re: CriteriaQuery and JPA
References <4e676e7b$1@news.x-privat.org> <fcd93a94-1fe2-42ee-aa7d-545df845d5c1@glegroupsg2000goo.googlegroups.com>
Message-ID <4e687355$2@news.x-privat.org> (permalink)
Organization X-Privat.Org NNTP Server - http://www.x-privat.org

Show all headers | View raw


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

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

CriteriaQuery and JPA Lele <lamia@mail.lcom> - 2011-09-07 15:15 +0200
  Re: CriteriaQuery and JPA Lew <lewbloch@gmail.com> - 2011-09-07 11:02 -0700
    Re: CriteriaQuery and JPA Lele <lele@lele.com> - 2011-09-08 09:48 +0200
    Re: CriteriaQuery and JPA Lele <lelel@lele.com> - 2011-09-08 15:03 +0200
      Re: CriteriaQuery and JPA markspace <-@.> - 2011-09-08 06:39 -0700
        Re: CriteriaQuery and JPA Lele <lelel@lele.com> - 2011-09-08 16:53 +0200
          Re: CriteriaQuery and JPA Lew <lewbloch@gmail.com> - 2011-09-08 09:05 -0700

csiph-web