Tabnine Logo
EntityMetamodel.getEntity
Code IndexAdd Tabnine to your IDE (free)

How to use
getEntity
method
in
com.blazebit.persistence.parser.EntityMetamodel

Best Java code snippets using com.blazebit.persistence.parser.EntityMetamodel.getEntity (Showing top 20 results out of 315)

origin: Blazebit/blaze-persistence

  @SuppressWarnings("unchecked")
  @Override
  public <X> BasicUserType<X> getBasicUserType(Class<X> clazz) {
    BasicUserType<?> userType = basicUserTypes.get(clazz);
    if (userType == null) {
      if (clazz.isEnum()) {
        // Enums are always considered immutable
        userType = ImmutableBasicUserType.INSTANCE;
      } else if (entityMetamodel.getEntity(clazz) != null) {
        userType = entityBasicUserType;
      } else if (Date.class.isAssignableFrom(clazz)) {
        userType = DateBasicUserType.INSTANCE;
      } else if (Calendar.class.isAssignableFrom(clazz)) {
        userType = CalendarBasicUserType.INSTANCE;
      } else {
        userType = MutableBasicUserType.INSTANCE;
      }
    }

    return (BasicUserType<X>) userType;
  }
}
origin: Blazebit/blaze-persistence

@Override
protected void validate(RepositoryMetadata repositoryMetadata) {
  super.validate(repositoryMetadata);
  if (cbf.getService(EntityMetamodel.class).getEntity(repositoryMetadata.getDomainType()) == null) {
    throw new InvalidDataAccessApiUsageException(
        String.format("Cannot implement repository %s when using a non-entity domain type %s. Only types annotated with @Entity are supported!",
            repositoryMetadata.getRepositoryInterface().getName(), repositoryMetadata.getDomainType().getName()));
  }
}
origin: com.blazebit/blaze-persistence-integration-spring-data-1.x

@Override
protected void validate(RepositoryMetadata repositoryMetadata) {
  super.validate(repositoryMetadata);
  if (cbf.getService(EntityMetamodel.class).getEntity(repositoryMetadata.getDomainType()) == null) {
    throw new InvalidDataAccessApiUsageException(
        String.format("Cannot implement repository %s when using a non-entity domain type %s. Only types annotated with @Entity are supported!",
            repositoryMetadata.getRepositoryInterface().getName(), repositoryMetadata.getDomainType().getName()));
  }
}
origin: Blazebit/blaze-persistence

@Override
public void visit(TreatExpression expression) {
  EntityType<?> type = metamodel.getEntity(expression.getType());
  currentPosition.setAttribute(null);
  currentPosition.setCurrentType(type);
}
origin: Blazebit/blaze-persistence

@Override
protected void validate(RepositoryMetadata repositoryMetadata) {
  super.validate(repositoryMetadata);
  if (cbf.getService(EntityMetamodel.class).getEntity(repositoryMetadata.getDomainType()) == null) {
    throw new InvalidDataAccessApiUsageException(
        String.format("Cannot implement repository %s when using a non-entity domain type %s. Only types annotated with @Entity are supported!",
            repositoryMetadata.getRepositoryInterface().getName(), repositoryMetadata.getDomainType().getName()));
  }
}
origin: Blazebit/blaze-persistence

@Override
protected void validate(RepositoryMetadata repositoryMetadata) {
  super.validate(repositoryMetadata);
  if (cbf.getService(EntityMetamodel.class).getEntity(repositoryMetadata.getDomainType()) == null) {
    throw new InvalidDataAccessApiUsageException(
        String.format("Cannot implement repository %s when using a non-entity domain type %s. Only types annotated with @Entity are supported!",
            repositoryMetadata.getRepositoryInterface().getName(), repositoryMetadata.getDomainType().getName()));
  }
}
origin: com.blazebit/blaze-persistence-integration-spring-data-2.0

@Override
protected void validate(RepositoryMetadata repositoryMetadata) {
  super.validate(repositoryMetadata);
  if (cbf.getService(EntityMetamodel.class).getEntity(repositoryMetadata.getDomainType()) == null) {
    throw new InvalidDataAccessApiUsageException(
        String.format("Cannot implement repository %s when using a non-entity domain type %s. Only types annotated with @Entity are supported!",
            repositoryMetadata.getRepositoryInterface().getName(), repositoryMetadata.getDomainType().getName()));
  }
}
origin: com.blazebit/blaze-persistence-integration-spring-data-2.1

@Override
protected void validate(RepositoryMetadata repositoryMetadata) {
  super.validate(repositoryMetadata);
  if (cbf.getService(EntityMetamodel.class).getEntity(repositoryMetadata.getDomainType()) == null) {
    throw new InvalidDataAccessApiUsageException(
        String.format("Cannot implement repository %s when using a non-entity domain type %s. Only types annotated with @Entity are supported!",
            repositoryMetadata.getRepositoryInterface().getName(), repositoryMetadata.getDomainType().getName()));
  }
}
origin: Blazebit/blaze-persistence

private static boolean shouldPassThrough(EntityViewManagerImpl evm, ManagedViewType<?> viewType, AbstractMethodAttribute<?, ?> attribute) {
  // For an attribute being eligible for pass through, the declaring view must be for an embeddable type
  // and the attribute must be update mappable
  return evm.getMetamodel().getEntityMetamodel().getEntity(viewType.getEntityClass()) == null
      && attribute.isUpdateMappable();
}
origin: com.blazebit/blaze-persistence-core-parser

@Override
public void visit(TreatExpression expression) {
  boolean handled = false;
  if (expression.getExpression() instanceof PathExpression) {
    PathExpression treatPath = (PathExpression) expression.getExpression();
    if (treatPath.getExpressions().size() == 1 && skipBaseNodeAlias.equals(treatPath.getExpressions().get(0).toString())) {
      // When we encounter a naked root treat like "TREAT(alias AS Subtype)" we always skip it
      handled = true;
    }
  }
  if (!handled) {
    expression.getExpression().accept(this);
  }
  EntityType<?> type = metamodel.getEntity(expression.getType());
  // TODO: should we check if the type is actually a sub- or super type?
  currentPosition.setCurrentType(type);
  currentPosition.setValueType(type);
}
origin: Blazebit/blaze-persistence

@Override
public void visit(TreatExpression expression) {
  boolean handled = false;
  if (expression.getExpression() instanceof PathExpression) {
    PathExpression treatPath = (PathExpression) expression.getExpression();
    if (treatPath.getExpressions().size() == 1 && skipBaseNodeAlias.equals(treatPath.getExpressions().get(0).toString())) {
      // When we encounter a naked root treat like "TREAT(alias AS Subtype)" we always skip it
      handled = true;
    }
  }
  if (!handled) {
    expression.getExpression().accept(this);
  }
  EntityType<?> type = metamodel.getEntity(expression.getType());
  // TODO: should we check if the type is actually a sub- or super type?
  currentPosition.setCurrentType(type);
  currentPosition.setValueType(type);
}
origin: Blazebit/blaze-persistence

public AbstractViewToEntityMapper(String attributeLocation, EntityViewManagerImpl evm, Class<?> viewTypeClass, Set<Type<?>> readOnlyAllowedSubtypes, Set<Type<?>> persistAllowedSubtypes, Set<Type<?>> updateAllowedSubtypes, EntityLoader entityLoader, AttributeAccessor viewIdAccessor, boolean persistAllowed, EntityViewUpdaterImpl owner, String ownerMapping) {
  this.attributeLocation = attributeLocation;
  ManagedViewTypeImplementor<?> managedViewTypeImplementor = evm.getMetamodel().managedView(viewTypeClass);
  this.isEmbeddable = evm.getMetamodel().getEntityMetamodel().getEntity(managedViewTypeImplementor.getEntityClass()) == null;
  Map<Class<?>, EntityViewUpdater> persistUpdater = new HashMap<>();
  Map<Class<?>, EntityViewUpdater> updateUpdater = new HashMap<>();
origin: Blazebit/blaze-persistence

private String createQueryString(EntityViewManagerImpl evm, ManagedViewType<?> subviewType) {
  EntityMetamodel entityMetamodel = evm.getMetamodel().getEntityMetamodel();
  EntityType<?> entityType = entityMetamodel.getEntity(entityClass);
  // We can't query embeddables
  if (entityType == null) {
    return null;
  }
  Set<String> fetchJoinableRelations = new HashSet<>(subviewType.getAttributes().size());
  addFetchJoinableRelations(fetchJoinableRelations, "", subviewType);
  CriteriaBuilderFactory cbf = evm.getCriteriaBuilderFactory();
  EntityManagerFactory emf = cbf.getService(EntityManagerFactory.class);
  EntityManager em = emf.createEntityManager();
  try {
    if (fetchJoinableRelations.isEmpty()) {
      return null;
    } else {
      return cbf.create(em, entityClass)
          .fetch(fetchJoinableRelations.toArray(new String[fetchJoinableRelations.size()]))
          .where(JpaMetamodelUtils.getSingleIdAttribute(entityType).getName()).eqExpression(":id")
          .getQueryString();
    }
  } finally {
    em.close();
  }
}
origin: Blazebit/blaze-persistence

public ObjectBuilder<?> createObjectBuilder(ManagedViewTypeImplementor<?> viewType, MappingConstructorImpl<?> mappingConstructor, String viewName, Class<?> rootType, String entityViewRoot, String embeddingViewPath, FullQueryBuilder<?, ?> criteriaBuilder, EntityViewConfiguration configuration, int offset, int suffix) {
  ExpressionFactory ef = criteriaBuilder.getService(ExpressionFactory.class);
  if (!viewType.getEntityClass().isAssignableFrom(rootType)) {
    if (rootType.isAssignableFrom(viewType.getEntityClass())) {
      entityViewRoot = "TREAT(" + entityViewRoot + " AS " + metamodel.getEntityMetamodel().getEntity(viewType.getJavaType()).getName() + ")";
    } else {
      throw new IllegalArgumentException("The given view type with the entity type '" + viewType.getEntityClass().getName()
          + "' can not be applied to the query builder with result type '" + rootType.getName() + "'");
    }
  }
  MacroConfiguration originalMacroConfiguration = ef.getDefaultMacroConfiguration();
  ExpressionFactory cachingExpressionFactory = ef.unwrap(AbstractCachingExpressionFactory.class);
  JpqlMacro viewRootJpqlMacro = new DefaultViewRootJpqlMacro(entityViewRoot);
  EmbeddingViewJpqlMacro embeddingViewJpqlMacro = configuration.getEmbeddingViewJpqlMacro();
  Map<String, MacroFunction> macros = new HashMap<>();
  macros.put("view_root", new JpqlMacroAdapter(viewRootJpqlMacro, cachingExpressionFactory));
  macros.put("embedding_view", new JpqlMacroAdapter(embeddingViewJpqlMacro, cachingExpressionFactory));
  MacroConfiguration macroConfiguration = originalMacroConfiguration.with(macros);
  ef = new MacroConfigurationExpressionFactory(cachingExpressionFactory, macroConfiguration);
  criteriaBuilder.registerMacro("view_root", viewRootJpqlMacro);
  return getTemplate(ef, viewType, mappingConstructor, viewName, entityViewRoot, embeddingViewPath, embeddingViewJpqlMacro, offset)
    .createObjectBuilder(criteriaBuilder, configuration.getOptionalParameters(), configuration, suffix);
}
origin: Blazebit/blaze-persistence

public Map<String, String> determineWritableMappedByMappings(ManagedType<?> managedType, String mappedBy, MetamodelBuildingContext context) {
  ViewMapping elementViewMapping = getElementViewMapping();
  EntityType<?> elementType;
  if (elementViewMapping != null) {
    elementType = context.getEntityMetamodel().getEntity(elementViewMapping.getEntityClass());
  } else {
    Class<?> declaredElementType = getDeclaredElementType();
    if (declaredElementType != null) {
      elementType = context.getEntityMetamodel().getEntity(declaredElementType);
    } else {
      elementType = context.getEntityMetamodel().getEntity(getDeclaredType());
    }
  }
  if (elementType == null) {
    return null;
  }
  EntityType<?> entityType = (EntityType<?>) managedType;
  try {
    Map<String, String> writableMappedByMappings = context.getJpaProvider().getWritableMappedByMappings(entityType, elementType, mappedBy, ((Mapping) mapping).value());
    if (writableMappedByMappings == null) {
      return null;
    } else {
      return Collections.unmodifiableMap(writableMappedByMappings);
    }
  } catch (RuntimeException ex) {
    // Graceful error message for cases when an inverse attribute was mapped on a wrong type
    context.addError("Couldn't determine writable mappings for the mapped by mapping '" + mappedBy + "' on the entity '" + elementType.getName() + "' declared by the entity '" + entityType.getName() + "' through a entity view mapping at the " + getErrorLocation());
    return null;
  }
}
origin: Blazebit/blaze-persistence

public AbstractUnmappedAttributeCascadeDeleter(EntityViewManagerImpl evm, String attributeName, ExtendedAttribute<?, ?> attribute) {
  EntityMetamodel entityMetamodel = evm.getMetamodel().getEntityMetamodel();
  this.elementEntityClass = attribute.getElementClass();
  this.attributeName = attributeName;
  if (entityMetamodel.getEntity(elementEntityClass) == null) {
    this.elementIdAttributeName = null;
    this.attributeValuePath = attributeName;
    this.cascadeDeleteElement = false;
  } else {
    ExtendedManagedType extendedManagedType = entityMetamodel.getManagedType(ExtendedManagedType.class, elementEntityClass);
    this.elementIdAttributeName = extendedManagedType.getIdAttribute().getName();
    this.attributeValuePath = attributeName + "." + elementIdAttributeName;
    this.cascadeDeleteElement = attribute.isDeleteCascaded();
  }
}
origin: Blazebit/blaze-persistence

EntityType<?> entityType = m.getEntity(rootNode.getJavaType());
if (entityType == null) {
origin: Blazebit/blaze-persistence

} else {
  subAttributes = new HashSet<>();
  EntityType<?> entity = evm.getMetamodel().getEntityMetamodel().getEntity(entityClass);
  for (String propertyName : evm.getJpaProvider().getIdentifierOrUniqueKeyEmbeddedPropertyNames(entity, mappingPrefix + attribute.getName())) {
    subAttributes.add(managedType.getAttribute(propertyName));
origin: Blazebit/blaze-persistence

  viewIdAccessor = Accessors.forViewId(evm, (ViewType<?>) viewType, true);
if (evm.getMetamodel().getEntityMetamodel().getEntity(viewType.getEntityClass()) == null) {
  Class<?> viewTypeClass = viewType.getJavaType();
  return new EmbeddableUpdaterBasedViewToEntityMapper(
origin: Blazebit/blaze-persistence

if (evm.getMetamodel().getEntityMetamodel().getEntity(viewType.getEntityClass()) == null) {
  return new EmbeddableUpdaterBasedViewToEntityMapper(
      attributeLocation,
com.blazebit.persistence.parserEntityMetamodelgetEntity

Popular methods of EntityMetamodel

  • getManagedType
  • managedType
  • type
  • entity

Popular in Java

  • Making http requests using okhttp
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Permission (java.security)
    Legacy security code; do not use.
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ImageIO (javax.imageio)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now