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


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

Re: CriteriaQuery and JPA

Date 2011-09-08 15:03 +0200
From Lele <lelel@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 <4e68bd21$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*.

UPDATE.
It's not the where clause causing problem... Infact even without where 
clause the result is always empty.
I try with this code:

CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery filter = criteriaBuilder.createQuery(MyClass.class);
Root<MyClass> from = filter.from(MyClass.class);
filter.select(from);
TypedQuery<MyClass> q = entityManager.createQuery(filter);	
List<MyClass> results = q.getResultList();

The resulting query is :
Hibernate: select myclass0_.username as username4_ from MYCLASS myclass0_

I tried with Query too:
String sQuery = "SELECT mc FROM MyClass mc ";
Query query = entityManager.createQuery(sQuery);
List<MyClass> results = query.getResultList();

but with no success...

What's the problem?? Can you help me??

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