类org.hibernate.annotations.NaturalId源码实例Demo

下面列出了怎么用org.hibernate.annotations.NaturalId的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: PropertyBinder.java
public Property makeProperty() {
	validateMake();
	LOG.debugf( "Building property %s", name );
	Property prop = new Property();
	prop.setName( name );
	prop.setValue( value );
	prop.setLazy( lazy );
	prop.setLazyGroup( lazyGroup );
	prop.setCascade( cascade );
	prop.setPropertyAccessorName( accessType.getType() );

	if ( property != null ) {
		prop.setValueGenerationStrategy( determineValueGenerationStrategy( property ) );

		if ( property.isAnnotationPresent( AttributeAccessor.class ) ) {
			final AttributeAccessor accessor = property.getAnnotation( AttributeAccessor.class );
			prop.setPropertyAccessorName( accessor.value() );
		}
	}

	NaturalId naturalId = property != null ? property.getAnnotation( NaturalId.class ) : null;
	if ( naturalId != null ) {
		if ( ! entityBinder.isRootEntity() ) {
			throw new AnnotationException( "@NaturalId only valid on root entity (or its @MappedSuperclasses)" );
		}
		if ( ! naturalId.mutable() ) {
			updatable = false;
		}
		prop.setNaturalIdentifier( true );
	}

	// HHH-4635 -- needed for dialect-specific property ordering
	Lob lob = property != null ? property.getAnnotation( Lob.class ) : null;
	prop.setLob( lob != null );

	prop.setInsertable( insertable );
	prop.setUpdateable( updatable );

	// this is already handled for collections in CollectionBinder...
	if ( Collection.class.isInstance( value ) ) {
		prop.setOptimisticLocked( ( (Collection) value ).isOptimisticLocked() );
	}
	else {
		final OptimisticLock lockAnn = property != null
				? property.getAnnotation( OptimisticLock.class )
				: null;
		if ( lockAnn != null ) {
			//TODO this should go to the core as a mapping validation checking
			if ( lockAnn.excluded() && (
					property.isAnnotationPresent( javax.persistence.Version.class )
							|| property.isAnnotationPresent( Id.class )
							|| property.isAnnotationPresent( EmbeddedId.class ) ) ) {
				throw new AnnotationException(
						"@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: "
								+ StringHelper.qualify( holder.getPath(), name )
				);
			}
		}
		final boolean isOwnedValue = !isToOneValue( value ) || insertable; // && updatable as well???
		final boolean includeInOptimisticLockChecks = ( lockAnn != null )
				? ! lockAnn.excluded()
				: isOwnedValue;
		prop.setOptimisticLocked( includeInOptimisticLockChecks );
	}

	LOG.tracev( "Cascading {0} with {1}", name, cascade );
	this.mappingProperty = prop;
	return prop;
}
 
源代码2 项目: ignite   文件: HibernateL2CacheSelfTest.java
/**
 * @return Name.
 */
@NaturalId(mutable = true)
public String getName() {
    return name;
}
 
源代码3 项目: ignite   文件: HibernateL2CacheSelfTest.java
/**
 * @return Name.
 */
@NaturalId(mutable = true)
public String getName() {
    return name;
}
 
源代码4 项目: ignite   文件: HibernateL2CacheSelfTest.java
/**
 * @return Name.
 */
@NaturalId(mutable = true)
public String getName() {
    return name;
}
 
源代码5 项目: ignite   文件: HibernateL2CacheSelfTest.java
/**
 * @return Name.
 */
@NaturalId(mutable = true)
public String getName() {
    return name;
}
 
源代码6 项目: ignite   文件: HibernateL2CacheSelfTest.java
/**
 * @return Name.
 */
@NaturalId(mutable = true)
public String getName() {
    return name;
}
 
源代码7 项目: ignite   文件: HibernateL2CacheSelfTest.java
/**
 * @return Name.
 */
@NaturalId(mutable = true)
public String getName() {
    return name;
}
 
 类所在包
 同包方法