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

Relationship cascading #148

Closed
denniseffing opened this issue Mar 6, 2017 · 2 comments
Closed

Relationship cascading #148

denniseffing opened this issue Mar 6, 2017 · 2 comments
Assignees

Comments

@denniseffing
Copy link

denniseffing commented Mar 6, 2017

Hi,

maybe I am doing something wrong, but I noticed that the save operation of a mocked repository doesn't save cascaded entities even though the CascadeType is set to ALL for the corresponding relationship.

Minimal code example:

public class ManyEntity {
    @ManyToOne
    @JoinColumn(<configuration here>)
    private OneEntity oneEntity;
}

public class OneEntity() {
    @OneToMany(mappedBy = "oneEntity",  cascade = { javax.persistence.CascadeType.ALL })
    private List<ManyEntity> manyEntities;
}

Mock setup:

// mocking repositories here..

// mock entities
ManyEntity manyEntity = new ManyEntity();
OneEntity oneEntity = new OneEntity();

// establish relationship
manyEntity.setOneEntity(oneEntity);

List<ManyEntity> manyEntitites = new LinkedList<>();
manyEntities.add(manyEntity);
oneEntity.setManyEntities(manyEntitites)

// save mocks
oneEntityRepository.save(oneEntity);

Expected vs. actual result:

oneEntityRepository.findAll().size() // expected: 1, actual result: 1
manyEntityRepository.findAll().size() // expected: 1, actual result: 0
@mmnaseri
Copy link
Owner

Hi,

Can I see how you have mocked your repositories? I believe this falls outside the supported use cases of the framework, but we may find a workaround.

@mmnaseri
Copy link
Owner

Closing due to lack of feedback.

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