This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

HQL -> Criteria....

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys : Im trying to express this HQL as a criteria statement and can't get it right.

Can somebody please help ?

Im confused because the field description is a String.
How can I make a criteria that returns an object that is not a mapped table-bean object ?
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry that HQL is incorrect, its actually
select distinct (r.description) from RefPmsusertag r
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My suggestion go through Criteria Documentation here : Hibernate Criteria Query

You create a criteria like this :

session.createCriteria(SomeClass.class,"ALIAS_").createAlias("ALIAS_.SOME_PROPERTY").setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();
you iterate through the list like this



Regards
Vyas, Anirudh
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe a full code snippet using the Criteria API will help. Here's a sample of getting a list of results:



To massage the results, you can start using Example or Restriction classes to help get the results you want. Here's an example:



I wrote a free tutorial on the subject of using the Criteria API with Hibernate. You might find it helpful:

How to Use the Criteria API with Hibernate - Simple Examples and Code Snippets

Good luck!

-Cameron McKenzie
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!