Results 1 to 3 of 3
  1. #1
    GlWy is offline Member
    Join Date
    Jan 2011
    Posts
    10
    Rep Power
    0

    Default hibernate distinct query

    Hi,

    I have a query, with many joins, executed by hibernate. This query contains many joins. Only some values from the database must be retrieved, and there can be several conditions in the where clause.
    Now the thing is that the same result is returned many times. So I used the DistinctRootEntityResultTransformer, unfortunately the result is still the same. I have written my code below. What is wrong with my implementation or is there another way?

    sql += "a large query with many joins";
    SQLQuery query = getSession().createSQLQuery(sql);

    List<Object[]> list = DistinctRootEntityResultTransformer.INSTANCE.trans formList(query.list());

    thanks for any help

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    Can't you use "select distinct <className>.<thing I'm interested in>..."?

  3. #3
    GlWy is offline Member
    Join Date
    Jan 2011
    Posts
    10
    Rep Power
    0

    Default

    Sometimes I can make it so difficult while it's so easy.

    thanks,

    it indeed did the trick

Similar Threads

  1. Java - hibernate query with join
    By dergotic in forum Advanced Java
    Replies: 0
    Last Post: 09-29-2010, 09:02 PM
  2. Hibernate Join Query - Should be easy
    By ajt111 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 10-29-2009, 05:48 PM
  3. Help query with hibernate
    By wonderbiker in forum JDBC
    Replies: 0
    Last Post: 04-14-2009, 11:12 AM
  4. Hibernate sql query
    By taicode in forum JDBC
    Replies: 0
    Last Post: 03-25-2008, 04:17 PM
  5. Replies: 0
    Last Post: 03-12-2008, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •