/** * @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; } } }
|| attribute.getDeclaringType().getPersistenceType() == Type.PersistenceType.EMBEDDABLE;
private String resolveRole(PluralAttribute attribute) { switch ( attribute.getDeclaringType().getPersistenceType() ) { case ENTITY: { return attribute.getDeclaringType().getJavaType().getName() + '.' + attribute.getName(); } while ( ( SingularAttributePath.class.isInstance( parentPath ) ) ); final EntityType entityType; if ( singularAttribute.getDeclaringType().getPersistenceType() == Type.PersistenceType.ENTITY ) { entityType = (EntityType) singularAttribute.getDeclaringType(); else if ( singularAttribute.getDeclaringType().getPersistenceType() == Type.PersistenceType.MAPPED_SUPERCLASS ){ String.format( "Unexpected PersistenceType: [%s]", singularAttribute.getDeclaringType().getPersistenceType() String.format( "Unexpected PersistenceType: [%s]", attribute.getDeclaringType().getPersistenceType()
/** * Returns true, if attribute is embeddable. * * @param embeddableClazz * class for embeddable type attribute. * @return try, if paramterized class is of embeddable java type. */ public boolean isEmbeddable(Class embeddableClazz) { return embeddables != null ? embeddables.containsKey(embeddableClazz) && embeddables.get(embeddableClazz).getPersistenceType().equals(PersistenceType.EMBEDDABLE) : false; }
if (superClazzType.getPersistenceType().equals(PersistenceType.ENTITY) && superClazzType.getJavaType().isAnnotationPresent(Inheritance.class))
/** * @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; } } }
private void encodeManagedType(ManagedType<?> type, Element parent) { Document doc = parent.getOwnerDocument(); Element root = doc.createElement(type.getPersistenceType().toString().toLowerCase()); parent.appendChild(root); root.setAttribute(ATTR_NAME, type.getJavaType().getSimpleName()); List<Attribute<?,?>> attributes = MetamodelHelper.getAttributesInOrder(type); for (Attribute<?,?> a : attributes) { String tag = MetamodelHelper.getTagByAttributeType(a); Element child = doc.createElement(tag); root.appendChild(child); child.setAttribute(ATTR_TYPE, typeOf(a.getJavaType())); if (a instanceof PluralAttribute) { if (a instanceof MapAttribute) { child.setAttribute(ATTR_KEY_TYPE, typeOf(((MapAttribute)a).getKeyJavaType())); child.setAttribute(ATTR_VALUE_TYPE, typeOf(((MapAttribute)a).getBindableJavaType())); } else { child.setAttribute(ATTR_MEMBER_TYPE, typeOf(((PluralAttribute)a).getBindableJavaType())); } } child.setTextContent(a.getName()); } }
List<Attribute<?, ?>> attributes = basicAttributePath.getAttributes(); for (int i = 1; i < attributes.size(); i++) { if (attributes.get(i).getDeclaringType().getPersistenceType() != Type.PersistenceType.EMBEDDABLE) {
public void initialize(Resources resources) { startMonitoring(); emf = Persistence.createEntityManagerFactory(persistenceUnitName, persistenceProperties); EntityManager em = null; try { em = emf.createEntityManager(); Metamodel meta = emf.getMetamodel(); meta.getManagedTypes().forEach(type -> { type.getDeclaredAttributes(); type.getPersistenceType(); }); } finally { if (em != null) em.close(); } NotificationCenter center = resources.getNotificationCenter(); center.subscribe(EvictCollectionRegion.class, notice -> evictCollectionRegion(notice.getUserObject())); center.subscribe(EvictEntityRegion.class, notice -> evictEntityRegion(notice.getUserObject())); center.subscribe(EvictEntity.class, notice -> evictEntity(notice.getUserObject())); }