if (attribute.isVersion()) { return Optional.of(attribute);
public static boolean isVersion(Attribute<?,?> a) { if (a instanceof SingularAttribute) return ((SingularAttribute<?,?>)a).isVersion(); return false; }
protected SingularAttribute<? super E, ?> getVersionAttribute(EntityType<E> entityType) { for (SingularAttribute<? super E, ?> sa : entityType.getSingularAttributes()) { if (sa.isVersion()) { return sa; } } return null; }
/** * _HACK_ too bad that JPA does not provide this entityType.getVersion(); * * @see http://stackoverflow.com/questions/13265094/generic-way-to-get-jpa-entity-version */ protected SingularAttribute<? super E, ?> getVersionAttribute(EntityType<E> entityType) { for (SingularAttribute<? super E, ?> sa : entityType.getSingularAttributes()) { if (sa.isVersion()) { return sa; } } return null; }
@Override public <Y> void addAttribute(Attribute<X, Y> attribute) { if (attribute instanceof SingularAttribute) { SingularAttribute<? super X, ?> sa = (SingularAttribute<? super X, ?>) attribute; if (sa.isId()) id = sa; if (sa.isVersion()) version = sa; } super.addAttribute(attribute); }
public static SingularAttribute<?, ?> getVersionAttribute(IdentifiableType<?> entityType) { if (!entityType.hasVersionAttribute()) { return null; } for (SingularAttribute<?, ?> attribute : entityType.getSingularAttributes()) { if (attribute.isVersion()) { return attribute; } } return null; }
public static SingularAttribute<?, ?> getVersionAttribute(IdentifiableType<?> entityType) { if (!entityType.hasVersionAttribute()) { return null; } for (SingularAttribute<?, ?> attribute : entityType.getSingularAttributes()) { if (attribute.isVersion()) { return attribute; } } return null; }
/** * Whether or not the identifiable type has a version attribute. * @return boolean indicating whether or not the identifiable * type has a version attribute */ public boolean hasVersionAttribute() { // The versionAttribute is lazy loaded if(null != versionAttribute) { return true; } else { for(Attribute attribute : this.getAttributes()) { if(!((AttributeImpl)attribute).isPlural() && ((SingularAttribute)attribute).isVersion()) { versionAttribute = (SingularAttribute)attribute; return true; } } } return false; }
if (attribute.isVersion()) { return Optional.of(attribute);
ExtendedAttribute<?, ?> extendedAttribute = entry.getValue(); SingularAttribute<?, ?> attribute = (SingularAttribute<?, ?>) extendedAttribute.getAttribute(); if (!attribute.isVersion() && !attribute.isOptional()) {
if (excludeAttr.contains(attr) || (style.excludeIdentity() && attr.isId()) || (style.excludeVersion() && attr.isVersion())) { continue;
if (excludeAttr.contains(attr) || (style.excludeIdentity() && attr.isId()) || (style.excludeVersion() && attr.isVersion())) { continue;
if (excludeAttr.contains(attr) || (style.excludeIdentity() && attr.isId()) || (style.excludeVersion() && attr.isVersion())) { continue;
if (excludeAttr.contains(attr) || (style.excludeIdentity() && attr.isId()) || (style.excludeVersion() && attr.isVersion())) { continue;
private VersionAttributeFlusher<Object, Object> createVersionFlusher(EntityViewManagerImpl evm, EntityType<?> entityType, AbstractMethodAttribute<?, ?> versionAttribute) { String attributeName = versionAttribute.getName(); String attributeMapping = versionAttribute.getMapping(); String parameterName = versionAttribute.getName(); String updateFragment = versionAttribute.getMapping(); AttributeAccessor viewAttributeAccessor = Accessors.forViewAttribute(evm, versionAttribute, false); AttributeAccessor attributeAccessor = Accessors.forEntityMapping(evm, versionAttribute); Type<?> type = ((com.blazebit.persistence.view.metamodel.SingularAttribute<?, ?>) versionAttribute).getType(); @SuppressWarnings("unchecked") VersionBasicUserType<Object> userType = (VersionBasicUserType<Object>) ((BasicType<?>) type).getUserType(); boolean jpaVersion = entityType.getSingularAttribute(versionAttribute.getMapping()).isVersion(); return new VersionAttributeFlusher<>(attributeName, attributeMapping, userType, updateFragment, parameterName, attributeAccessor, viewAttributeAccessor, jpaVersion); }