本文整理了Java中javax.persistence.metamodel.Metamodel.managedType()
方法的一些代码示例,展示了Metamodel.managedType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metamodel.managedType()
方法的具体详情如下:
包路径:javax.persistence.metamodel.Metamodel
类名称:Metamodel
方法名:managedType
[英]Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.
[中]
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* @param value
* @return {@literal true} if the given value is not {@literal null} and a mapped persistable entity otherwise
* {@literal false}
*/
private boolean isIdentifierDerivationNecessary(@Nullable Object value) {
if (value == null) {
return false;
}
try {
ManagedType<? extends Object> managedType = this.metamodel.managedType(ClassUtils.getUserClass(value));
return managedType != null && managedType.getPersistenceType() == PersistenceType.ENTITY;
} catch (IllegalArgumentException iae) {
// no mapped type
return false;
}
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Returns the {@link Metamodel} aware of the given type.
*
* @param type must not be {@literal null}.
* @return can be {@literal null}.
*/
@Nullable
private Metamodel getMetamodelFor(Class<?> type) {
for (Metamodel model : metamodels) {
try {
model.managedType(type);
return model;
} catch (IllegalArgumentException o_O) {
// Fall back to inspect *all* managed types manually as Metamodel.managedType(…) only
// returns for entities, embeddables and managed supperclasses.
for (ManagedType<?> managedType : model.getManagedTypes()) {
if (type.equals(managedType.getJavaType())) {
return model;
}
}
}
}
return null;
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Creates a new {@link JpaMetamodelEntityInformation} for the given domain class and {@link Metamodel}.
*
* @param domainClass must not be {@literal null}.
* @param metamodel must not be {@literal null}.
*/
public JpaMetamodelEntityInformation(Class<T> domainClass, Metamodel metamodel) {
super(domainClass);
Assert.notNull(metamodel, "Metamodel must not be null!");
this.metamodel = metamodel;
ManagedType<T> type = metamodel.managedType(domainClass);
if (type == null) {
throw new IllegalArgumentException("The given domain class can not be found in the given Metamodel!");
}
this.entityName = type instanceof EntityType ? ((EntityType<?>) type).getName() : null;
if (!(type instanceof IdentifiableType)) {
throw new IllegalArgumentException("The given domain class does not contain an id attribute!");
}
IdentifiableType<T> identifiableType = (IdentifiableType<T>) type;
this.idMetadata = new IdMetadata<T>(identifiableType);
this.versionAttribute = findVersionAttribute(identifiableType, metamodel);
}
代码示例来源:origin: spring-projects/spring-data-jpa
private String tryFindSingularIdAttributeNameOrUseFallback(Class<? extends Object> idPropertyValueType,
String fallbackIdTypePropertyName) {
ManagedType<? extends Object> idPropertyType = metamodel.managedType(idPropertyValueType);
for (SingularAttribute<?, ?> sa : idPropertyType.getSingularAttributes()) {
if (sa.isId()) {
return sa.getName();
}
}
return fallbackIdTypePropertyName;
}
代码示例来源:origin: spring-projects/spring-data-jpa
ManagedType<?> managedSuperType = metamodel.managedType(superType);
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
ManagedType mt = mm.managedType(clazz);
try {
Attribute attr = mt.getAttribute(piece);
代码示例来源:origin: Blazebit/blaze-persistence
@Override
public <X> ManagedType<X> managedType(Class<X> cls) {
return delegate.managedType(cls);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
protected <T> Expression<T> buildExpressionForAs(Class<T> type) {
managedType = metamodel.managedType(type);
currentNode = currentNode.treat(type);
return (Expression<T>)this;
}
代码示例来源:origin: org.fornax.cartridges/fornax-cartridges-sculptor-framework
/**
*
* @param path
* @param type
* @param entity
* @return
*/
protected List<Predicate> preparePredicates(Object entity) {
return preparePredicates(root, metaModel.managedType(getType()), entity);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public <X, T extends X> Path<T> treat(Path<X> path, Class<T> type) {
//Handle all the paths that might get passed in.:
PathImpl parentPath = (PathImpl)path;
PathImpl newPath = (PathImpl)parentPath.clone();
newPath.currentNode = newPath.currentNode.treat(type);
newPath.pathParent = parentPath;
newPath.javaType = type;
newPath.modelArtifact = this.metamodel.managedType(type);
return newPath;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public <X, T, V extends T> Join<X, V> treat(Join<X, T> join, Class<V> type) {
JoinImpl parentJoin = (JoinImpl)join;
JoinImpl joinImpl = new JoinImpl<X, V>(parentJoin, this.metamodel.managedType(type), this.metamodel,
type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
parentJoin.joins.add(joinImpl);
joinImpl.isJoin = parentJoin.isJoin;
parentJoin.isJoin = false;
return joinImpl;
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
private String tryFindSingularIdAttributeNameOrUseFallback(Class<? extends Object> idPropertyValueType,
String fallbackIdTypePropertyName) {
ManagedType<? extends Object> idPropertyType = metamodel.managedType(idPropertyValueType);
for (SingularAttribute<?, ?> sa : idPropertyType.getSingularAttributes()) {
if (sa.isId()) {
return sa.getName();
}
}
return fallbackIdTypePropertyName;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
@SuppressWarnings({ "unchecked" })
public SingularAttributeJoin(
CriteriaBuilderImpl criteriaBuilder,
Class<X> javaType,
PathSource<Z> pathSource,
SingularAttribute<? super Z, ?> joinAttribute,
JoinType joinType) {
super( criteriaBuilder, javaType, pathSource, joinAttribute, joinType );
this.model = (Bindable<X>) (
Attribute.PersistentAttributeType.EMBEDDED == joinAttribute.getPersistentAttributeType()
? joinAttribute
: criteriaBuilder.getEntityManagerFactory().getMetamodel().managedType( javaType )
);
}
代码示例来源:origin: org.infinispan/infinispan-cachestore-jpa
private SingularAttribute getEntityId(EntityManager em, Class clazz) {
Metamodel meta = em.getMetamodel();
IdentifiableType identifiableType = (IdentifiableType) meta.managedType(clazz);
return identifiableType.getId(identifiableType.getIdType().getJavaType());
}
代码示例来源:origin: Blazebit/blaze-persistence
protected String getEntityIdName(Class<?> entityClass) {
ManagedType<?> managedType = entityViewConfiguration.getCriteriaBuilder().getMetamodel().managedType(entityClass);
if (JpaMetamodelUtils.isIdentifiable(managedType)) {
return JpaMetamodelUtils.getSingleIdAttribute((IdentifiableType<?>) managedType).getName();
} else {
return null;
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Correlates a join to a Map-valued association or element collection in
* the enclosing query to a join object of the subquery and returns the
* subquery join object.
*
* @param parentMap
* join target of the containing query
* @return subquery join
*/
public <X, K, V> MapJoin<X, K, V> correlate(MapJoin<X, K, V> parentCollection){
this.correlatedJoins.add(parentCollection);
return new MapJoinImpl(parentCollection.getParentPath(), metamodel.managedType(parentCollection.getModel().getBindableJavaType()), metamodel, parentCollection.getJavaType(), internalCorrelate((FromImpl) parentCollection), parentCollection.getModel(), parentCollection.getJoinType(), (FromImpl) parentCollection);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Correlates a join to a Set-valued association or element collection in
* the enclosing query to a join object of the subquery and returns the
* subquery join object.
*
* @param parentSet
* join target of the containing query
* @return subquery join
*/
public <X, Y> SetJoin<X, Y> correlate(SetJoin<X, Y> parentCollection){
this.correlatedJoins.add(parentCollection);
return new SetJoinImpl(parentCollection.getParentPath(), metamodel.managedType(parentCollection.getModel().getBindableJavaType()), metamodel, parentCollection.getJavaType(), ((InternalSelection)parentCollection).getCurrentNode(), parentCollection.getModel(), parentCollection.getJoinType(), (FromImpl) parentCollection);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public <X, T, E extends T> ListJoin<X, E> treat(ListJoin<X, T> join, Class<E> type) {
ListJoinImpl parentJoin = (ListJoinImpl)join;
ListJoin joinImpl = null;
if (join instanceof BasicListJoinImpl) {
joinImpl = new BasicListJoinImpl<X, E>(parentJoin, this.metamodel, type,
parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
} else {
joinImpl = new ListJoinImpl<X, E>((Path)join, this.metamodel.managedType(type), this.metamodel,
type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
}
parentJoin.joins.add(joinImpl);
((FromImpl)joinImpl).isJoin = parentJoin.isJoin;
parentJoin.isJoin = false;
return joinImpl;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public <X, T, E extends T> SetJoin<X, E> treat(SetJoin<X, T> join, Class<E> type) {
SetJoinImpl parentJoin = (SetJoinImpl)join;
SetJoin joinImpl = null;
if (join instanceof BasicSetJoinImpl) {
joinImpl = new BasicSetJoinImpl<X, E>(parentJoin, this.metamodel, type,
parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
} else {
joinImpl = new SetJoinImpl<X, E>((Path)join, this.metamodel.managedType(type), this.metamodel,
type, parentJoin.currentNode.treat(type), parentJoin.getModel(), parentJoin.getJoinType());
}
parentJoin.joins.add(joinImpl);
((FromImpl)joinImpl).isJoin = parentJoin.isJoin;
parentJoin.isJoin = false;
return joinImpl;
}
代码示例来源:origin: babyfish-ct/babyfish
@SuppressWarnings("unchecked")
protected Bindable<X> onGetModel() {
SingularAttribute<? super Z, ?> attribute = this.getAttribute();
if (Attribute.PersistentAttributeType.EMBEDDED == attribute.getPersistentAttributeType()) {
return (Bindable<X>)attribute;
}
return (Bindable<X>)this.getCriteriaBuilder().getEntityManagerFactory().getMetamodel().managedType(this.getJavaType());
}
内容来源于网络,如有侵权,请联系作者删除!