Skip to content
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

ClassCastException with @Autowired Spring JpaRepositories #294

Closed
beatjost opened this issue Jun 15, 2016 · 2 comments
Closed

ClassCastException with @Autowired Spring JpaRepositories #294

beatjost opened this issue Jun 15, 2016 · 2 comments
Assignees
Labels
bug

Comments

@beatjost
Copy link

@beatjost beatjost commented Jun 15, 2016

We have several test which run until version 1.21 of JMockit. From version 1.22 we get a 'ClassCastException'. The problem there is that the spring JpaRepository retuns a repository instance itself instead of a generic domain class.

Repository

public interface StateRepository extends JpaRepository<State, Long> {
   ...

Runtime code

@Autowired
StateRepository stateRepo;
...
activity.setState(stateRepo.findOne(stateId));  //returns repo instead of domain pojo

JUnit test

@Tested
StateUpdater stateUpdater;
@Injectable
StateRepository stateRepo;

@rliesenfeld rliesenfeld added the bug label Jun 15, 2016
@rliesenfeld rliesenfeld self-assigned this Jun 15, 2016
@rliesenfeld

This comment has been minimized.

Copy link
Member

@rliesenfeld rliesenfeld commented Jun 15, 2016

It's a bug.

Thanks for reporting!

@beatjost

This comment has been minimized.

Copy link
Author

@beatjost beatjost commented Jun 20, 2016

Thanks for fast fixing - will check next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.