Announcement Announcement Module
Collapse
No announcement yet.
spring data jpa M2 query findBy did not work for non-id fields Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring data jpa M2 query findBy did not work for non-id fields

    I have a simple application which tries out the spring data jpa M2 release. I have this repository defined:
    public interface fooRepository extends JpaRepository<Foo, String> {
    // query by ID
    List<Foo> findByFooId(String fooId);

    List<Foo> findByRating(String rating);
    }

    the FooId is a @Id field in the domain model, and Rating is a normal field. The first method will always work, but the second one always return 0 rows. Is there anything special about the fields that are not id?
    Spring data jpa did simplify a lot of things, if this query works!
    -much thanks as always-

  • #2
    Hi,

    Could you enable trace to see executed SQL?

    My $.02 is that you try to query a char[x] column and not a varchar column. (you then need to some space to your rating...)

    Comment


    • #3
      I saw that the debugging hibernate sql code has something likefor a select statement)

      ... cast(null as date) as from_date, ....

      And the 'date' is not valid for SQL Server, so I manually changed it to 'datetime' and the query worked. So my question is:
      how should I let it (Spring Data) generate 'datetime', and also I see 'joda time' in this project (I didn't start this project), and that is having issues with hibernate 3.6, could this be the reason?

      -thanks

      Comment

      Working...
      X