當前位置: 首頁>>代碼示例>>Java>>正文


Java Version類代碼示例

本文整理匯總了Java中javax.persistence.Version的典型用法代碼示例。如果您正苦於以下問題:Java Version類的具體用法?Java Version怎麽用?Java Version使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Version類屬於javax.persistence包,在下文中一共展示了Version類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isPostable

import javax.persistence.Version; //導入依賴的package包/類
@Override
public Optional<Boolean> isPostable(BeanAttributeInformation attributeDesc) {
	Optional<Column> column = attributeDesc.getAnnotation(Column.class);
	Optional<Version> version = attributeDesc.getAnnotation(Version.class);
	if (!version.isPresent() && column.isPresent()) {
		return Optional.of(column.get().insertable());
	}
	Optional<GeneratedValue> generatedValue = attributeDesc.getAnnotation(GeneratedValue.class);
	if (generatedValue.isPresent()) {
		return Optional.of(false);
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:14,代碼來源:JpaResourceFieldInformationProvider.java

示例2: isPatchable

import javax.persistence.Version; //導入依賴的package包/類
@Override
public Optional<Boolean> isPatchable(BeanAttributeInformation attributeDesc) {
	Optional<Column> column = attributeDesc.getAnnotation(Column.class);
	Optional<Version> version = attributeDesc.getAnnotation(Version.class);
	if (!version.isPresent() && column.isPresent()) {
		return Optional.of(column.get().updatable());
	}
	Optional<GeneratedValue> generatedValue = attributeDesc.getAnnotation(GeneratedValue.class);
	if (generatedValue.isPresent()) {
		return Optional.of(false);
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:14,代碼來源:JpaResourceFieldInformationProvider.java

示例3: include

import javax.persistence.Version; //導入依賴的package包/類
private boolean include(Class<?> type, PropertyDescriptor descriptor) {
   Field field = findField(type, descriptor.getName());
   if (field == null) {
      return false;
   }
   if (hasAnnotation(Version.class, descriptor.getReadMethod(), field)) {
      return false;
   }
   if (hasAnnotation(Transient.class, descriptor.getReadMethod(), field)) {
      return false;
   }
   if (Modifier.isStatic(field.getModifiers())) {
      return false;
   }
   if (Modifier.isTransient(field.getModifiers())) {
      return false;
   }
   return true;
}
 
開發者ID:Wolfgang-Winter,項目名稱:cibet,代碼行數:20,代碼來源:EntityIntrospector.java

示例4: buildProperty

import javax.persistence.Version; //導入依賴的package包/類
/**
 * Builds the property for the given attribute.
 *
 * @param attribute
 *            the attribute to inspect
 * @param columnMetadata
 *            the attached (or overriden) column metadata
 * @param override
 *            the AssociationOverride found for this attribute
 * @return the property that represents the attribute or {@code null} if not persistent
 */
<X> Property<X, ?> buildProperty(final AttributeAccessor attribute, final Column columnMetadata,
		final AssociationOverride override) {
	if (attribute.isPersistent()) {
		if (CollectionProperty.isCollectionProperty(attribute)) {
			return new CollectionProperty<>(this, attribute, override);
		} else if (MapProperty.isMapProperty(attribute)) {
			return new MapProperty<>(this, attribute, override);
		} else if (EntityProperty.isEntityProperty(attribute)) {
			return new EntityProperty<>(this.context, getTable(), attribute, override);
		} else if (attribute.isAnnotationPresent(Embedded.class)) {
			return new EmbeddedProperty<>(this, attribute);
		} else if (attribute.isAnnotationPresent(Version.class)) {
			return new VersionProperty<>(this.context, this.table, attribute, columnMetadata);
		} else {
			return new PrimitiveProperty<>(this.context, this.table, attribute, columnMetadata);
		}
	}
	return null;
}
 
開發者ID:liefke,項目名稱:org.fastnate,代碼行數:31,代碼來源:EntityClass.java

示例5: getVersionProperty

import javax.persistence.Version; //導入依賴的package包/類
public static Property<Serializable> getVersionProperty(Class<?> entityClass)
{
    List<PropertyCriteria> criteriaList = new LinkedList<PropertyCriteria>();
    criteriaList.add(new AnnotatedPropertyCriteria(Version.class));

    String fromMappingFiles = PersistenceUnitDescriptorProvider.getInstance().versionField(entityClass);
    if (fromMappingFiles != null)
    {
        criteriaList.add(new NamedPropertyCriteria(fromMappingFiles));
    }

    for (PropertyCriteria criteria : criteriaList)
    {
        PropertyQuery<Serializable> query =
            PropertyQueries.<Serializable> createQuery(entityClass).addCriteria(criteria);
        Property<Serializable> result = query.getFirstResult();
        if (result != null)
        {
            return result;
        }
    }

    return null;
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:25,代碼來源:EntityUtils.java

示例6: process

import javax.persistence.Version; //導入依賴的package包/類
@Override
public Object process(AnnotationInfo ctx, Object value) {
    if (ctx.isAnnotationPresent(Id.class)
            || ctx.isAnnotationPresent(Version.class)) {
        return null;
    }
    return value;
}
 
開發者ID:randomito,項目名稱:randomito-all,代碼行數:9,代碼來源:NullifyIdVersionPostProcessor.java

示例7: getRecVersionFieldName

import javax.persistence.Version; //導入依賴的package包/類
public static String getRecVersionFieldName(Class<? extends BaseMybatisModel> modelClass) {
    for (Method method : modelClass.getMethods()) {
        String methodName = method.getName();
        if (method.isAnnotationPresent(Version.class)) {
            return methodName.substring(3, 4).toLowerCase() + methodName.substring(4);
        }
    }
    return null;
}
 
開發者ID:xmomen,項目名稱:easy-mybatis,代碼行數:10,代碼來源:ModelUtils.java

示例8: getRecVersionColumnName

import javax.persistence.Version; //導入依賴的package包/類
public static String getRecVersionColumnName(Class<? extends BaseMybatisModel> modelClass) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
    for (Method method : modelClass.getMethods()) {
        if (method.isAnnotationPresent(Version.class)) {
            for (int i = 0; i < method.getAnnotations().length; i++) {
                Annotation annotation = method.getAnnotations()[i];
                if (annotation.annotationType().equals(Column.class)) {
                    Method annotationMethod = annotation.getClass().getDeclaredMethod("name", method.getParameterTypes());
                    return annotationMethod.invoke(annotation, null).toString();
                }
            }
        }
    }
    return null;
}
 
開發者ID:xmomen,項目名稱:easy-mybatis,代碼行數:15,代碼來源:ModelUtils.java

示例9: hasJpaAnnotations

import javax.persistence.Version; //導入依賴的package包/類
private boolean hasJpaAnnotations(MetaAttribute attribute) {
	List<Class<? extends Annotation>> annotationClasses = Arrays.asList(Id.class, EmbeddedId.class, Column.class,
			ManyToMany.class, ManyToOne.class, OneToMany.class, OneToOne.class, Version.class,
			ElementCollection.class);
	for (Class<? extends Annotation> annotationClass : annotationClasses) {
		if (attribute.getAnnotation(annotationClass) != null) {
			return true;
		}
	}
	return false;
}
 
開發者ID:katharsis-project,項目名稱:katharsis-framework,代碼行數:12,代碼來源:AbstractEntityMetaProvider.java

示例10: initializeChecks

import javax.persistence.Version; //導入依賴的package包/類
protected void initializeChecks(final Column annotation, final Collection<Check> checks, final AccessibleObject fieldOrMethod) {
    /* If the value is generated (annotated with @GeneratedValue) it is allowed to be null
     * before the entity has been persisted, same is true in case of optimistic locking
     * when a field is annotated with @Version.
     * Therefore and because of the fact that there is no generic way to determine if an entity
     * has been persisted already, a not-null check will not be performed for such fields.
     */
    if (!annotation.nullable() && !fieldOrMethod.isAnnotationPresent(GeneratedValue.class) && !fieldOrMethod.isAnnotationPresent(Version.class)
            && !fieldOrMethod.isAnnotationPresent(NotNull.class))
        if (!containsCheckOfType(checks, NotNullCheck.class))
            checks.add(new NotNullCheck());

    // add Length check based on Column.length parameter, but only:
    if (!fieldOrMethod.isAnnotationPresent(Lob.class) && // if @Lob is not present
            !fieldOrMethod.isAnnotationPresent(Enumerated.class) && // if @Enumerated is not present
            !fieldOrMethod.isAnnotationPresent(Length.class) // if an explicit @Length constraint is not present
    ) {
        final LengthCheck lengthCheck = new LengthCheck();
        lengthCheck.setMax(annotation.length());
        checks.add(lengthCheck);
    }

    // add Range check based on Column.precision/scale parameters, but only:
    if (!fieldOrMethod.isAnnotationPresent(Range.class) // if an explicit @Range is not present
            && annotation.precision() > 0 // if precision is > 0
            && Number.class.isAssignableFrom(fieldOrMethod instanceof Field ? ((Field) fieldOrMethod).getType() : ((Method) fieldOrMethod).getReturnType()) // if numeric field type
    ) {
        /* precision = 6, scale = 2  => -9999.99<=x<=9999.99
         * precision = 4, scale = 1  =>   -999.9<=x<=999.9
         */
        final RangeCheck rangeCheck = new RangeCheck();
        rangeCheck.setMax(Math.pow(10, annotation.precision() - annotation.scale()) - Math.pow(0.1, annotation.scale()));
        rangeCheck.setMin(-1 * rangeCheck.getMax());
        checks.add(rangeCheck);
    }
}
 
開發者ID:sebthom,項目名稱:oval,代碼行數:37,代碼來源:JPAAnnotationsConfigurer.java

示例11: getVersion

import javax.persistence.Version; //導入依賴的package包/類
/**
 * <p>Getter for the field <code>version</code>.</p>
 *
 * @return a {@link java.lang.Integer} object.
 */
@Version
@Column(name="VERSION")
public Integer getVersion()
{
    return this.version;
}
 
開發者ID:strator-dev,項目名稱:greenpepper,代碼行數:12,代碼來源:AbstractEntity.java

示例12: getEntityVersion

import javax.persistence.Version; //導入依賴的package包/類
@Column(name = DbColumnNames.ENTITY_VERSION)
@Nullable
@Override
@Version
public Long getEntityVersion() {
    return this.entityVersion;
}
 
開發者ID:esacinc,項目名稱:sdcct,代碼行數:8,代碼來源:SdcctResourceImpl.java

示例13: getModificationCounter

import javax.persistence.Version; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
@Version
@Column(name = "version")
public int getModificationCounter() {

  return super.getModificationCounter();
}
 
開發者ID:m-m-m,項目名稱:persistence,代碼行數:11,代碼來源:AbstractJpaEntity.java

示例14: getVersion

import javax.persistence.Version; //導入依賴的package包/類
/**
 * Get the version for the attached file.
 * @return the version for the attached file
 * @motivation for hibernate
 */
@Column(nullable=false)
@Version
private Integer getVersion()
{
  return _version;
}
 
開發者ID:hmsiccbl,項目名稱:screensaver,代碼行數:12,代碼來源:AttachedFile.java

示例15: getVersion

import javax.persistence.Version; //導入依賴的package包/類
/**
 * @motivation for hibernate
 */
@Version
@Column(nullable = false)
private Integer getVersion()
{
  return _version;
}
 
開發者ID:hmsiccbl,項目名稱:screensaver,代碼行數:10,代碼來源:LibraryContentsVersion.java


注:本文中的javax.persistence.Version類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。