Skip to content

Spring-Data-Commons 1.13.1-RELEASE causes custom repo to not be called. #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ryonday opened this issue Mar 13, 2017 · 3 comments
Open

Comments

@ryonday
Copy link

ryonday commented Mar 13, 2017

I've spent a few hours on this bug and have tracked down the root cause, but am still searching for a workaround/solution.

  • spring-data-dynamoDB version: 4.5.0
  • Spring-data-commons version: 1.13.1-RELEASE

I have a base repository interface:

package com.foo.repository;
import com.foo.stuff.Foo;
import org.springframework.data.repository.CrudRepository;
public interface FooRepository extends CrudRepository<Foo, Long>, FooRepositoryCustom{}

...and a custom repository interface:

package com.foo.repository;
import com.foo.stuff.Foo;
public interface UserRepositoryCustom {
    Foo doNonstandardThing(Foo foo);
}

... and a custom repository implementation:

package com.foo.repository.impl;
import com.foo.stuff.Foo;
public class UserRepositoryImpl implements UserRepositoryCustom {
    public Foo save(Foo foo) {
        // Do things
    }
    public Foo doNonstandardThing(Foo foo){}
}

... If I use this custom repository:

package com.foo.service;
import com.foo.stuff.Foo;
import com.foo.stuff.Bar;

@Service
public class FooService {
    private final FooRepository fooRepo;
    
    @Autowired
    public FooService(FooRepository fooRepo) {
        this.fooRepo = fooRepo;
    }

    public Bar processFoo(Foo foo) {
        fold(foo);
        spindle(foo);      
        mutilate(foo);
        fooRepo.save(foo);
    }
}

With spring-data-dynamodb:4.2.3 using spring-data-commons:1.11.4-RELEASE, the fooRepo::save call in FooService would call the save method on FooRepositoryCustom. with spring-data-dynamodb:4.5.0 and spring-data-commons:1.13.1-RELEASE, it actually calls org.socialsignin.spring.data.dynamodb.repository.support.SimpleDynamoDBCrudRepository::save!

I've tracked this down to this commit and a few other changes within DefaultRepositoryInformation and specifically, the parametersMatch method.

What I can't figure out is why exactly the SimpleDynamoDBCrudRepository::save method is overriding my custom repository.

EDIT: Correct some Markdown

@ryonday
Copy link
Author

ryonday commented Mar 13, 2017

I've managed to work around this by doing the following:

package com.foo.repository;
import com.foo.stuff.Foo;
import org.springframework.data.repository.CrudRepository;
public interface FooRepository extends CrudRepository<Foo, Long>, FooRepositoryCustom{
    @Override
    <X extends Foo> X save(X foo);
}

Unfortunately, this means that I have to do this for all of my DynamoDB repositories that have methods that a custom Repository implementation overrides.

This is also contrary to the Spring documentation which at least implies that the only methods that need to be declared in the custom repository interface are custom queries and the like.

@ryonday
Copy link
Author

ryonday commented Mar 13, 2017

I also opened A JIRA ticket against spring-data-commons because I believe that the fault lies there. I opened this ticket mainly for informational purposes.

EDIT: mental context switch between JIRA markup and Markdown caused Markdown errors

derjust added a commit that referenced this issue Nov 29, 2017
Sadly the fix as per https://jira.spring.io/browse/DATACMNS-1008 doesn't
work. Only the workaround does - Therefore this test fails right now :(
@derjust
Copy link
Owner

derjust commented Nov 30, 2017

Issue still/again exists in spring-data-commons 2.0.0 till 2.0.2: https://jira.spring.io/browse/DATACMNS-1225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants