use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.
the class EntityViewMetamodelFlatViewTest method updatableMutableFlatView.
@Test
public void updatableMutableFlatView() {
ViewMetamodel metamodel = build(entityViewConfiguration, DocumentViewWithUpdatableMutableFlatView.class, NameObjectView.class, NameObjectUpdateView.class).getMetamodel();
ManagedViewType<?> nameObjectViewType = metamodel.managedView(NameObjectUpdateView.class);
ManagedViewType<?> docViewType = metamodel.managedView(DocumentViewWithUpdatableMutableFlatView.class);
assertTrue(docViewType.getAttribute("nameObject").isUpdatable());
assertTrue(docViewType.getAttribute("nameObject").isPersistCascaded());
assertTrue(docViewType.getAttribute("nameObject").isUpdateCascaded());
assertTrue(docViewType.getAttribute("nameObject").getPersistCascadeAllowedSubtypes().contains(nameObjectViewType));
assertTrue(docViewType.getAttribute("nameObject").getUpdateCascadeAllowedSubtypes().contains(nameObjectViewType));
assertTrue(docViewType.getAttribute("nameObject").isMutable());
}
use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.
the class EntityViewMetamodelTest method updatableMutableAndCreatableView.
@Test
public void updatableMutableAndCreatableView() {
EntityViewConfiguration cfg = EntityViews.createDefaultConfiguration();
cfg.setProperty(ConfigurationProperties.PROXY_EAGER_LOADING, "true");
cfg.setProperty(ConfigurationProperties.UPDATER_EAGER_LOADING, "true");
cfg.setProperty(ConfigurationProperties.UPDATER_DISALLOW_OWNED_UPDATABLE_SUBVIEW, "false");
ViewMetamodel metamodel = build(cfg, DocumentViewWithUpdatableMutableAndCreatableViewTypes.class, PersonCreateAndUpdateView.class).getMetamodel();
ManagedViewType<?> docViewType = metamodel.managedView(DocumentViewWithUpdatableMutableAndCreatableViewTypes.class);
// By default, the collection relations are not updatable
assertTrue(docViewType.getAttribute("partners").isUpdatable());
assertTrue(docViewType.getAttribute("owner").isUpdatable());
assertTrue(docViewType.getAttribute("people").isUpdatable());
// Updatable attributes with mutable types cascade only UPDATE by default
assertTrue(docViewType.getAttribute("partners").isPersistCascaded());
assertTrue(docViewType.getAttribute("owner").isPersistCascaded());
assertTrue(docViewType.getAttribute("people").isPersistCascaded());
assertTrue(docViewType.getAttribute("partners").isUpdateCascaded());
assertTrue(docViewType.getAttribute("owner").isUpdateCascaded());
assertTrue(docViewType.getAttribute("people").isUpdateCascaded());
// An attribute is mutable if it's updatable or the type is mutable
assertTrue(docViewType.getAttribute("partners").isMutable());
assertTrue(docViewType.getAttribute("owner").isMutable());
assertTrue(docViewType.getAttribute("people").isMutable());
}
use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.
the class EntityViewMetamodelTest method nonUpdatableEntityAttributeDefaults.
@Test
public void nonUpdatableEntityAttributeDefaults() {
ViewMetamodel metamodel = build(entityViewConfiguration, DocumentViewWithEntityTypes.class).getMetamodel();
ManagedViewType<?> docViewType = metamodel.managedView(DocumentViewWithEntityTypes.class);
// By default, the collection relations are not updatable
assertFalse(docViewType.getAttribute("partners").isUpdatable());
assertFalse(docViewType.getAttribute("owner").isUpdatable());
// Cascades require the update to be updatable, so they are all disabled
assertFalse(docViewType.getAttribute("partners").isPersistCascaded());
assertFalse(docViewType.getAttribute("owner").isPersistCascaded());
assertTrue(docViewType.getAttribute("partners").isUpdateCascaded());
assertTrue(docViewType.getAttribute("owner").isUpdateCascaded());
// Entity types are mutable
assertTrue(docViewType.getAttribute("partners").isMutable());
assertTrue(docViewType.getAttribute("owner").isMutable());
}
use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.
the class EntityViewMetamodelTest method updatableMutableViewAttributeDefaults.
@Test
public void updatableMutableViewAttributeDefaults() {
EntityViewConfiguration cfg = EntityViews.createDefaultConfiguration();
cfg.setProperty(ConfigurationProperties.PROXY_EAGER_LOADING, "true");
cfg.setProperty(ConfigurationProperties.UPDATER_EAGER_LOADING, "true");
cfg.setProperty(ConfigurationProperties.UPDATER_DISALLOW_OWNED_UPDATABLE_SUBVIEW, "false");
ViewMetamodel metamodel = build(cfg, DocumentViewWithUpdatableMutableViewTypes.class, PersonUpdateView.class).getMetamodel();
ManagedViewType<?> docViewType = metamodel.managedView(DocumentViewWithUpdatableMutableViewTypes.class);
// By default, the collection relations are not updatable
assertTrue(docViewType.getAttribute("partners").isUpdatable());
assertTrue(docViewType.getAttribute("owner").isUpdatable());
assertTrue(docViewType.getAttribute("people").isUpdatable());
// Updatable attributes with mutable types cascade only UPDATE by default
assertFalse(docViewType.getAttribute("partners").isPersistCascaded());
assertFalse(docViewType.getAttribute("owner").isPersistCascaded());
assertFalse(docViewType.getAttribute("people").isPersistCascaded());
assertTrue(docViewType.getAttribute("partners").isUpdateCascaded());
assertTrue(docViewType.getAttribute("owner").isUpdateCascaded());
assertTrue(docViewType.getAttribute("people").isUpdateCascaded());
// An attribute is mutable if it's updatable or the type is mutable
assertTrue(docViewType.getAttribute("partners").isMutable());
assertTrue(docViewType.getAttribute("owner").isMutable());
assertTrue(docViewType.getAttribute("people").isMutable());
}
use of com.blazebit.persistence.view.metamodel.ViewMetamodel in project blaze-persistence by Blazebit.
the class ViewMetamodelTest method testMappingAttributeInterfaceInheritedClassView.
@Test
public void testMappingAttributeInterfaceInheritedClassView() throws Exception {
ViewMetamodel viewMetamodel = getViewMetamodel();
ViewType<?> viewType = viewMetamodel.view(DocumentViewAbstractClass.class);
MethodAttribute<?, ?> attribute = viewType.getAttribute("id");
assertNotNull(attribute);
assertEquals("id", attribute.getName());
assertFalse(attribute.isSubquery());
assertEquals("id", ((MappingAttribute<?, ?>) attribute).getMapping());
assertFalse(attribute.isCollection());
assertFalse(((SingularAttribute<?, ?>) attribute).isQueryParameter());
assertEquals(Long.class, attribute.getJavaType());
assertEquals(IdHolderView.class.getMethod("getId"), attribute.getJavaMethod());
assertEquals(viewType, attribute.getDeclaringType());
}
Aggregations