Results 1 to 4 of 4

Thread: Sort by field of embeded object not work in Spring Data JPA

  1. #1
    Join Date
    Apr 2011
    Posts
    4

    Question Sort by field of embeded object not work in Spring Data JPA

    Hello, guys,

    I am using Spring Data JPA in one of our project. The JPA structure like:

    Class A {
    B b;
    String c;
    }

    Class B {
    String d;
    }

    I wanna do a query on Class A but sort by b.d. How can I do it? I cannot find any clue on Spring Data JPA document.
    Last edited by Layne_Peng; Oct 11th, 2011 at 11:20 AM.

  2. #2
    Join Date
    Apr 2011
    Posts
    4

    Default

    I wanna explained here. I hope the sort is dynamical when the sort field given by client, instead use @OrderBy annotation.

  3. #3
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    new Sort("b.d", Direction.ASC) should do the trick.

  4. #4
    Join Date
    Apr 2011
    Posts
    4

    Default

    Quote Originally Posted by Oliver Gierke View Post
    new Sort("b.d", Direction.ASC) should do the trick.
    Which version of Spring Data you are mentioned. I am using 1.0.0 M3, not work.
    Exception raised out:
    at org.hibernate.ejb.criteria.path.AbstractPathImpl.u nknownAttribute(AbstractPathImpl.java:110)

Tags for this Thread

Posting Permissions

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