本文整理汇总了Java中javax.persistence.metamodel.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于javax.persistence.metamodel包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import javax.persistence.metamodel.Type; //导入依赖的package包/类
public Attribute<?, ?> filter() {
Type<?> type = forModel(metamodel).filter(rootType);
Attribute<?, ?> result = null;
for (int i = 1; i < pathElements.length; i++) {
if (!(type instanceof ManagedType)) {
throw new PersistenceException("Cannot navigate through simple property "
+ pathElements[i] + " of type " + type.getJavaType());
}
result = ((ManagedType<?>)type).getAttribute(pathElements[i]);
if (result.isCollection()) {
type = ((PluralAttribute<?, ?, ?>)result).getElementType();
} else {
type = ((SingularAttribute<?, ?>)result).getType();
}
}
return result;
}
示例2: toType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
public static Type toType(Bindable bindable) {
switch ( bindable.getBindableType() ) {
case ENTITY_TYPE: {
return (EntityType) bindable;
}
case SINGULAR_ATTRIBUTE: {
return ( (SingularAttribute) bindable ).getType();
}
case PLURAL_ATTRIBUTE: {
return ( (PluralAttribute) bindable ).getElementType();
}
default: {
throw new ParsingException( "Unexpected Bindable type : " + bindable );
}
}
}
示例3: getIdType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<?> getIdType() {
if ( getHierarchy().getIdentifierDescriptor() instanceof IdentifierDescriptorSingleAttribute ) {
final SingularAttribute idAttribute = ( (IdentifierDescriptorSingleAttribute) getHierarchy().getIdentifierDescriptor() )
.getIdAttribute();
if ( idAttribute instanceof SingularAttributeBasic ) {
return ( (SingularAttributeBasic) idAttribute ).getOrmType();
}
else if ( idAttribute instanceof SingularAttributeEmbedded ) {
return ( (SingularAttributeEmbedded) idAttribute ).getEmbeddablePersister();
}
else {
throw new IllegalStateException( "Expected BASIC or EMBEDDED attribute type for identifier" );
}
}
return null;
}
示例4: getElementType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<java.lang.String> getElementType() {
return new Type<java.lang.String>() {
@Override
public Class<java.lang.String> getJavaType() {
return java.lang.String.class;
}
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
return null;
}
};
}
示例5: getSelectedPath
import javax.persistence.metamodel.Type; //导入依赖的package包/类
private Path getSelectedPath(int index, javax.persistence.criteria.Path<?> path) {
if (path.getParentPath() != null) {
Type<?> type = getType(path.getModel());
if (type.getPersistenceType() == PersistenceType.BASIC
|| type.getPersistenceType() == PersistenceType.EMBEDDABLE) {
return getSelectedPath(index, path.getParentPath());
}
return getSelectedPath(index, path.getParentPath()).append(getName(path.getModel()));
}
if (path.getAlias() == null) {
path.alias("alias" + index);
}
return new Path(path.getAlias());
}
示例6: getSelectedType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
private Class<?> getSelectedType(javax.persistence.criteria.Path<?> path) {
Type<?> type = getType(path.getModel());
if (type.getPersistenceType() == PersistenceType.BASIC
|| type.getPersistenceType() == PersistenceType.EMBEDDABLE) {
return getSelectedType(path.getParentPath());
} else {
return type.getJavaType();
}
}
示例7: getElementType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <R> Type<R> getElementType(Attribute<?, ?> attr) {
if (attr instanceof SingularAttribute) {
return ((SingularAttribute<?,R>) attr).getType();
} else {
return ((PluralAttribute<?,?,R>)attr).getElementType();
}
}
示例8: getSubclasses
import javax.persistence.metamodel.Type; //导入依赖的package包/类
public static Set<Class> getSubclasses(Class<?> parent, EntityManager entityManager) {
return entityManager.getMetamodel().getEntities().stream()
.filter(entityType -> parent != entityType.getJavaType() && parent.isAssignableFrom(entityType.getJavaType()))
.map(Type::getJavaType)
.collect(Collectors.toCollection(HashSet::new));
}
示例9: initialize
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Before
public void initialize() throws ParseException, NoSuchMethodException {
Metamodel metamodel = mock(Metamodel.class);
SecurePersistenceUnitUtil persistenceUnitUtil = mock(SecurePersistenceUnitUtil.class);
accessManager = mock(DefaultAccessManager.class);
SecurityContext securityContext = mock(SecurityContext.class);
EntityType entityType = mock(EntityType.class);
SingularAttribute idAttribute = mock(SingularAttribute.class);
SingularAttribute nameAttribute = mock(SingularAttribute.class);
SingularAttribute parentAttribute = mock(SingularAttribute.class);
PluralAttribute childrenAttribute = mock(PluralAttribute.class);
MapAttribute relatedAttribute = mock(MapAttribute.class);
Type integerType = mock(Type.class);
when(metamodel.getEntities()).thenReturn(Collections.<EntityType<?>>singleton(entityType));
when(metamodel.managedType(MethodAccessTestBean.class)).thenReturn(entityType);
when(metamodel.entity(MethodAccessTestBean.class)).thenReturn(entityType);
when(accessManager.getContext()).thenReturn(securityContext);
when(securityContext.getAliases()).thenReturn(Collections.singleton(CURRENT_PRINCIPAL));
when(securityContext.getAliasValue(CURRENT_PRINCIPAL)).thenReturn(NAME);
when(entityType.getName()).thenReturn(MethodAccessTestBean.class.getSimpleName());
when(entityType.getJavaType()).thenReturn((Class)MethodAccessTestBean.class);
when(entityType.getAttributes()).thenReturn(new HashSet(Arrays.asList(
idAttribute, nameAttribute, parentAttribute, childrenAttribute, relatedAttribute)));
when(entityType.getAttribute("id")).thenReturn(idAttribute);
when(entityType.getAttribute("name")).thenReturn(nameAttribute);
when(entityType.getAttribute("parent")).thenReturn(parentAttribute);
when(entityType.getAttribute("children")).thenReturn(childrenAttribute);
when(entityType.getAttribute("related")).thenReturn(relatedAttribute);
when(idAttribute.getName()).thenReturn("id");
when(idAttribute.isCollection()).thenReturn(false);
when(idAttribute.getType()).thenReturn(integerType);
when(idAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
when(idAttribute.getJavaType()).thenReturn(Integer.TYPE);
when(idAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getId"));
when(nameAttribute.getName()).thenReturn("name");
when(nameAttribute.isCollection()).thenReturn(false);
when(nameAttribute.getType()).thenReturn(integerType);
when(nameAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
when(nameAttribute.getJavaType()).thenReturn(String.class);
when(nameAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getName"));
when(parentAttribute.getName()).thenReturn("parent");
when(parentAttribute.isCollection()).thenReturn(false);
when(parentAttribute.getType()).thenReturn(entityType);
when(parentAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.MANY_TO_ONE);
when(parentAttribute.getJavaType()).thenReturn(MethodAccessTestBean.class);
when(parentAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getParent"));
when(childrenAttribute.getName()).thenReturn("children");
when(childrenAttribute.isCollection()).thenReturn(true);
when(childrenAttribute.getElementType()).thenReturn(entityType);
when(childrenAttribute.getJavaMember())
.thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getChildren"));
when(relatedAttribute.getName()).thenReturn("related");
when(relatedAttribute.isCollection()).thenReturn(true);
when(relatedAttribute.getKeyJavaType()).thenReturn(MethodAccessTestBean.class);
when(relatedAttribute.getBindableJavaType()).thenReturn(MethodAccessTestBean.class);
when(relatedAttribute.getElementType()).thenReturn(entityType);
when(relatedAttribute.getJavaMember())
.thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getRelated"));
entityFilter = new EntityFilter(metamodel, persistenceUnitUtil, initializeAccessRules(metamodel));
DefaultAccessManager.Instance.register(accessManager);
}
示例10: getElementType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Type<E> getElementType() {
return getElementDescriptor();
}
示例11: getType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type getType() {
return getEmbeddablePersister();
}
示例12: getType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type getType() {
return getOrmType();
}
示例13: getIdType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<?> getIdType() {
return null;
}
示例14: getPersistenceType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
return null;
}
示例15: getType
import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<T> getType() {
return null;
}