-
May 10th, 2011, 04:38 PM
#1
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-
-
May 11th, 2011, 12:25 PM
#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...)
-
May 11th, 2011, 03:14 PM
#3
I saw that the debugging hibernate sql code has something like
for 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
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
-
Forum Rules