本文整理了Java中org.hibernate.annotations.common.reflection.XProperty
类的一些代码示例,展示了XProperty
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XProperty
类的具体详情如下:
包路径:org.hibernate.annotations.common.reflection.XProperty
类名称:XProperty
[英]A member which actually is a property (as per the JavaBean spec) Note that the same underlying artefact can be represented as both XProperty and XMethod The underlying layer does not guaranty that xProperty == xMethod if the underlying artefact is the same However xProperty.equals(xMethod) is supposed to return true
[中]实际上是属性的成员(根据JavaBean规范)注意,相同的底层构件可以同时表示为XProperty和XMethod。如果底层构件是相同的XProperty,底层并不保证XProperty==XMethod。equals(xMethod)应该返回true
代码示例来源:origin: hibernate/hibernate-orm
public XClass getPropertyClass() throws MappingException {
if ( property.isAnnotationPresent( Target.class ) ) {
return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() );
}
else {
return property.getType();
}
}
代码示例来源:origin: hibernate/hibernate-orm
final CollectionBinder result;
if ( property.isArray() ) {
if ( property.getElementClass().isPrimitive() ) {
result = new PrimitiveArrayBinder();
else if ( property.isCollection() ) {
final Class<?> returnedClass = property.getCollectionClass();
result = basicBinder;
else if ( property.isAnnotationPresent( CollectionType.class ) ) {
Class<?> semanticsClass = property.getAnnotation( CollectionType.class ).semantics();
throw new AnnotationException(
returnedClass.getName() + " collection type not supported for property: "
+ StringHelper.qualify( entityName, property.getName() )
);
throw new AnnotationException(
"Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: "
+ StringHelper.qualify( entityName, property.getName() )
);
final CollectionType typeAnnotation = property.getAnnotation( CollectionType.class );
if ( typeAnnotation != null ) {
final String typeName = typeAnnotation.type();
代码示例来源:origin: hibernate/hibernate-orm
public XClass getClassOrElement() throws MappingException {
if ( property.isAnnotationPresent( Target.class ) ) {
return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() );
}
else {
return property.getClassOrElementClass();
}
}
代码示例来源:origin: hibernate/hibernate-orm
private static boolean mustBeSkipped(XProperty property) {
//TODO make those hardcoded tests more portable (through the bytecode provider?)
return property.isAnnotationPresent( Transient.class )
|| "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( property.getType().getName() )
|| "org.hibernate.bytecode.internal.javassist.FieldHandler".equals( property.getType().getName() );
}
}
代码示例来源:origin: hibernate/hibernate-commons-annotations
public void testCanBeAnArrayOfPrimitives() {
List<XProperty> declaredProperties = dadAsSeenFromSon.getDeclaredProperties( "property" );
XProperty p = getPropertyNamed_from( "primitiveArrayProperty", declaredProperties );
assertTrue( factory.equals( p.getType(), int[].class ) );
assertTrue( factory.equals( p.getElementClass(), int.class ) );
assertTrue( factory.equals( p.getClassOrElementClass(), int.class ) );
assertNull( p.getCollectionClass() );
assertNull( p.getMapKey() );
assertTrue( p.isArray() );
assertFalse( p.isCollection() );
}
代码示例来源:origin: hibernate/hibernate-orm
private static boolean discoverTypeWithoutReflection(XProperty p) {
if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
.targetEntity()
.equals( void.class ) ) {
return true;
else if ( p.isAnnotationPresent( OneToMany.class ) && !p.getAnnotation( OneToMany.class )
.targetEntity()
.equals( void.class ) ) {
return true;
else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( ManyToOne.class )
.targetEntity()
.equals( void.class ) ) {
return true;
else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation( ManyToMany.class )
.targetEntity()
.equals( void.class ) ) {
return true;
else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
return true;
else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
if ( !p.isCollection() && !p.isArray() ) {
throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
else if ( p.isAnnotationPresent( Type.class ) ) {
return true;
代码示例来源:origin: hibernate/hibernate-orm
if ( property.isArray() ) {
returnedClassOrElement = property.getElementClass();
isArray = true;
isNationalized = property.isAnnotationPresent( Nationalized.class )
|| buildingContext.getBuildingOptions().useNationalizedCharacterData();
if ( (!key && property.isAnnotationPresent( Type.class ))
|| (key && property.isAnnotationPresent( MapKeyType.class )) ) {
if ( key ) {
MapKeyType ann = property.getAnnotation( MapKeyType.class );
annType = ann.value();
annType = property.getAnnotation( Type.class );
else if ( ( !key && property.isAnnotationPresent( Temporal.class ) )
|| ( key && property.isAnnotationPresent( MapKeyTemporal.class ) ) ) {
else if ( !key && property.isAnnotationPresent( Lob.class ) ) {
isLob = true;
if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, java.sql.Clob.class ) ) {
else if ( ( !key && property.isAnnotationPresent( Enumerated.class ) )
|| ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) ) {
final Class attributeJavaType = buildingContext.getBootstrapContext().getReflectionManager().toClass( returnedClassOrElement );
if ( !Enum.class.isAssignableFrom( attributeJavaType ) ) {
"Attribute [%s.%s] was annotated as enumerated, but its java type is not an enum [%s]",
declaringClassName,
代码示例来源:origin: hibernate/hibernate-orm
if ( property.isAnnotationPresent( MapKeyClass.class ) ) {
target = property.getAnnotation( MapKeyClass.class ).value();
mapKeyType = property.getMapKey().getName();
代码示例来源:origin: org.hibernate.orm/hibernate-core
if ( navigableXProperty.isArray() ) {
returnedClassOrElement = navigableXProperty.getElementClass();
isArray = true;
buildingContext.getBootstrapContext()
.getReflectionManager()
.toClass( navigableXProperty.getType() )
);
isLob = navigableXProperty.isAnnotationPresent( Lob.class );
isNationalized = navigableXProperty.isAnnotationPresent( Nationalized.class )
|| buildingContext.getBuildingOptions().useNationalizedCharacterData();
final MapKeyType mapKeyTypeAnn = navigableXProperty.getAnnotation( MapKeyType.class );
if ( mapKeyTypeAnn != null ) {
explicitTypeAnn = mapKeyTypeAnn.value();
explicitTypeAnn = navigableXProperty.getAnnotation( Type.class );
switch ( kind ) {
case COLLECTION_ID: {
final XClass valueClass = navigableXProperty.getClassOrElementClass();
basicValue.setJavaClass(
buildingContext.getBootstrapContext().getReflectionManager().toClass( valueClass )
代码示例来源:origin: hibernate/hibernate-orm
String accessType) {
for ( XProperty property : clazz.getDeclaredProperties( accessType ) ) {
final RevisionNumber revisionNumber = property.getAnnotation( RevisionNumber.class );
final RevisionTimestamp revisionTimestamp = property.getAnnotation( RevisionTimestamp.class );
final ModifiedEntityNames modifiedEntityNames = property.getAnnotation( ModifiedEntityNames.class );
final XClass revisionNumberClass = property.getType();
if ( reflectionManager.equals( revisionNumberClass, Integer.class ) ||
reflectionManager.equals( revisionNumberClass, Integer.TYPE ) ) {
revisionInfoIdData = new PropertyData( property.getName(), property.getName(), accessType, null );
revisionNumberFound.set();
revisionInfoIdData = new PropertyData( property.getName(), property.getName(), accessType, null );
revisionNumberFound.set();
final Column revisionPropColumn = property.getAnnotation( Column.class );
if ( revisionPropColumn != null ) {
revisionPropSqlType = revisionPropColumn.columnDefinition();
final XClass revisionTimestampClass = property.getType();
if ( reflectionManager.equals( revisionTimestampClass, Long.class ) ||
reflectionManager.equals( revisionTimestampClass, Long.TYPE ) ||
reflectionManager.equals( revisionTimestampClass, java.sql.Date.class ) ) {
revisionInfoTimestampData = new PropertyData(
property.getName(),
property.getName(),
accessType,
null
代码示例来源:origin: hibernate/hibernate-orm
private void validateLobMappingSupport(XProperty property) {
// HHH-9834 - Sanity check
try {
if ( property.isAnnotationPresent( ElementCollection.class ) ) {
if ( property.isAnnotationPresent( Lob.class ) ) {
if ( !property.getCollectionClass().isAssignableFrom( Map.class ) ) {
throw new MappingException(
"@ElementCollection combined with @Lob is only supported for Map collection types."
);
}
}
}
}
catch ( MappingException e ) {
throw new HibernateException(
String.format(
"Invalid mapping in [%s] for property [%s]",
property.getDeclaringClass().getName(),
property.getName()
),
e
);
}
}
代码示例来源:origin: hibernate/hibernate-search
throw log.cannotHaveTwoSpatialsWithDefaultOrSameName( member.getType().getName() );
propertyMetadataBuilder.addDocumentField( fieldMetadata );
if ( member.isCollection() ) {
parseContext.collectUnqualifiedCollectionRole( member.getName() );
代码示例来源:origin: hibernate/hibernate-orm
.isAnnotationPresent( ManyToOne.class )
|| entityPropertyData.getProperty().isAnnotationPresent( OneToOne.class );
final boolean isOfDifferentType = !entityPropertyData.getClassOrElement()
.equals( idClassPropertyData.getClassOrElement() );
if ( property.isAnnotationPresent( GeneratedValue.class ) &&
property.isAnnotationPresent( Id.class ) ) {
GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
String generatorType = generatedValue != null
? generatorType( generatedValue, buildingContext, property.getType() )
: "assigned";
String generator = generatedValue != null ?
buildGenerators( property, buildingContext );
SecondPass secondPass = new IdGeneratorResolverSecondPass(
(SimpleValue) comp.getProperty( property.getName() ).getValue(),
property,
generatorType,
localGenerators.putAll( buildGenerators( property, buildingContext ) );
BinderHelper.makeIdGenerator(
(SimpleValue) comp.getProperty( property.getName() ).getValue(),
property,
generatorType,
代码示例来源:origin: hibernate/hibernate-orm
private static Class<?> getTargetEntityClass(XProperty property) {
final ManyToOne mTo = property.getAnnotation( ManyToOne.class );
if (mTo != null) {
return mTo.targetEntity();
}
final OneToOne oTo = property.getAnnotation( OneToOne.class );
if (oTo != null) {
return oTo.targetEntity();
}
throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private boolean mappingDefinedAttributeOverrideOnMapKey(XProperty property) {
if ( property.isAnnotationPresent( AttributeOverride.class ) ) {
return namedMapKey( property.getAnnotation( AttributeOverride.class ) );
}
if ( property.isAnnotationPresent( AttributeOverrides.class ) ) {
final AttributeOverrides annotations = property.getAnnotation( AttributeOverrides.class );
for ( AttributeOverride attributeOverride : annotations.value() ) {
if ( namedMapKey( attributeOverride ) ) {
return true;
}
}
}
return false;
}
代码示例来源:origin: hibernate/hibernate-orm
descriptor.getDomainValueResolvedType().getSignature(),
conversionSite.getSiteDescriptor(),
xProperty.getDeclaringClass().getName(),
xProperty.getName(),
xProperty.getType().getName()
);
"Multiple auto-apply converters matched %s [%s.%s] : %s",
conversionSite.getSiteDescriptor(),
xProperty.getDeclaringClass().getName(),
xProperty.getName(),
StringHelper.join( matches, RENDERER )
代码示例来源:origin: hibernate/hibernate-orm
LOG.debugf( "Starting applyAttributeConverter [%s:%s]", persistentClassName, property.getName() );
if ( property.isAnnotationPresent( Id.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for Id attribute [%s]", property.getName() );
return;
LOG.debugf( "Skipping AttributeConverter checks for version attribute [%s]", property.getName() );
return;
if ( !key && property.isAnnotationPresent( Temporal.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for Temporal attribute [%s]", property.getName() );
return;
if ( key && property.isAnnotationPresent( MapKeyTemporal.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyTemporal [%s]", property.getName() );
return;
if ( !key && property.isAnnotationPresent( Enumerated.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for Enumerated attribute [%s]", property.getName() );
return;
if ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyEnumerated [%s]", property.getName() );
return;
LOG.debugf( "Skipping AttributeConverter checks for association attribute [%s]", property.getName() );
return;
代码示例来源:origin: org.hibernate.orm/hibernate-core
final Class javaType = buildingContext.getBootstrapContext()
.getReflectionManager()
.toClass( mapAttribute.getMapKey() );
basicValue.setJavaClass( javaType );
.getOrMakeJavaDescriptor( javaType );
final MapKeyType mapKeyTypeAnn = mapAttribute.getAnnotation( MapKeyType.class );
if ( mapKeyTypeAnn != null ) {
final MapKeyTemporal mapKeyTemporalAnn = mapAttribute.getAnnotation( MapKeyTemporal.class );
if ( mapKeyTemporalAnn != null ) {
temporalPrecision = mapKeyTemporalAnn.value();
final MapKeyEnumerated enumeratedAnn = mapAttribute.getAnnotation( MapKeyEnumerated.class );
if ( enumeratedAnn == null ) {
enumType = javax.persistence.EnumType.ORDINAL;
throw new IllegalStateException(
"javax.persistence.EnumType was null on @javax.persistence.MapKeyEnumerated " +
" associated with attribute " + mapAttribute.getDeclaringClass().getName() +
'.' + mapAttribute.getName()
);
代码示例来源:origin: hibernate/hibernate-orm
private TemporalType getTemporalType(XProperty property) {
if ( key ) {
MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class );
return ann.value();
}
else {
Temporal ann = property.getAnnotation( Temporal.class );
return ann.value();
}
}
代码示例来源:origin: hibernate/hibernate-orm
public String getPropertyName() throws MappingException {
return property.getName();
}
内容来源于网络,如有侵权,请联系作者删除!