Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Polymorphism for spring data?

  1. #11
    Join Date
    May 2011
    Posts
    4

    Default

    That worked. Thank you.

  2. #12

    Default

    Is support for interfaces as a domain type https://jira.springsource.org/browse/DATADOC-131 going to be extended to find methods?

    In the attached zipped example I have declared a finder:

    public interface PersonRepository extends PagingAndSortingRepository<Person, String> {

    List<Person> findByLastName( String lastName );
    }


    This causes template instantiation to fail with the below:

    Caused by: java.lang.IllegalArgumentException: No property last found for type interface org.acme.Person
    at org.springframework.data.repository.query.parser.P roperty.<init>(Property.java:66)
    at org.springframework.data.repository.query.parser.P roperty.<init>(Property.java:100)
    at org.springframework.data.repository.query.parser.P roperty.create(Property.java:300)
    at org.springframework.data.repository.query.parser.P roperty.create(Property.java:314)
    at org.springframework.data.repository.query.parser.P roperty.create(Property.java:280)
    at org.springframework.data.repository.query.parser.P roperty.from(Property.java:239)
    at org.springframework.data.repository.query.parser.P roperty.from(Property.java:227)
    at org.springframework.data.repository.query.parser.P art.<init>(Part.java:48)
    at org.springframework.data.repository.query.parser.P artTree$OrPart.<init>(PartTree.java:242)
    at org.springframework.data.repository.query.parser.P artTree.buildTree(PartTree.java:101)
    at org.springframework.data.repository.query.parser.P artTree.<init>(PartTree.java:77)
    at org.springframework.data.document.mongodb.reposito ry.PartTreeMongoQuery.<init>(PartTreeMongoQuery.ja va:42)
    ...


    Debugging it appears when Spring MongoDB attempts to "bind" using reflection it uses reflectionUtils.findField() which will calls Class.getDeclaredFields(). Put another way it just looks at fields and does not look at getters and setters which is all the interface has. Could it be changed to be able to bing to getters/setters, or alternatively bind later when it gets the concrete class?

    Last question - any target release date for DATADOC-131 ?

    Thanks

    Jacob
    Attached Files Attached Files

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

    Default

    Commented on the ticket. In short: that's exactly what the ticket is all about. The ticket is scheduled for 1.1-M1. As we're just on the road to 1.0-RC1 and GA so it will probably take a while.

  4. #14

    Default

    Matthias S,

    Can you provide a full xml config for you comments above as its not exactly clear how to make the adjustments you are suggesting.

Posting Permissions

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