Search in sources :

Example 1 with UpdatableDocumentView

use of com.blazebit.persistence.view.testsuite.update.remove.cascade.nested.model.UpdatableDocumentView in project blaze-persistence by Blazebit.

the class EntityViewRemoveNestedSubviewTest method testSimpleRemove.

@Test
public void testSimpleRemove() {
    // Given
    final UpdatableDocumentView docView = getDoc1View();
    clearQueries();
    // When
    remove(docView);
    // Then
    AssertStatementBuilder builder = assertUnorderedQuerySequence();
    if (!isQueryStrategy()) {
        // Hibernate loads the entities before deleting?
        builder.select(Person.class).select(Person.class).select(Document.class).select(Version.class);
    }
    if (isQueryStrategy()) {
        // Need to select the version id to be able to delete the localized set
        builder.select(Version.class);
    }
    deleteDocumentOwned(builder);
    deletePersonOwned(builder, true);
    deletePersonOwned(builder, true);
    // document.responsiblePerson.friend
    builder.delete(Person.class).update(Document.class).delete(Person.class).update(Document.class).delete(Version.class).delete(Version.class, "localized").delete(Document.class).validate();
    clearPersistenceContextAndReload();
    assertNull(doc1);
    assertNull(p1);
    assertNull(p3);
}
Also used : UpdatableDocumentView(com.blazebit.persistence.view.testsuite.update.remove.cascade.nested.model.UpdatableDocumentView) AssertStatementBuilder(com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder) Version(com.blazebit.persistence.testsuite.entity.Version) Document(com.blazebit.persistence.testsuite.entity.Document) Person(com.blazebit.persistence.testsuite.entity.Person) Test(org.junit.Test) AbstractEntityViewRemoveDocumentTest(com.blazebit.persistence.view.testsuite.update.remove.cascade.AbstractEntityViewRemoveDocumentTest)

Aggregations

AssertStatementBuilder (com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder)1 Document (com.blazebit.persistence.testsuite.entity.Document)1 Person (com.blazebit.persistence.testsuite.entity.Person)1 Version (com.blazebit.persistence.testsuite.entity.Version)1 AbstractEntityViewRemoveDocumentTest (com.blazebit.persistence.view.testsuite.update.remove.cascade.AbstractEntityViewRemoveDocumentTest)1 UpdatableDocumentView (com.blazebit.persistence.view.testsuite.update.remove.cascade.nested.model.UpdatableDocumentView)1 Test (org.junit.Test)1