public XClass getPropertyClass() throws MappingException { if ( property.isAnnotationPresent( Target.class ) ) { return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() ); } else { return property.getType(); } }
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();
public XClass getClassOrElement() throws MappingException { if ( property.isAnnotationPresent( Target.class ) ) { return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() ); } else { return property.getClassOrElementClass(); } }
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() ); } }
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() ); }
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;
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,
if ( property.isAnnotationPresent( MapKeyClass.class ) ) { target = property.getAnnotation( MapKeyClass.class ).value(); mapKeyType = property.getMapKey().getName();
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 )
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
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 ); } }
throw log.cannotHaveTwoSpatialsWithDefaultOrSameName( member.getType().getName() ); propertyMetadataBuilder.addDocumentField( fieldMetadata ); if ( member.isCollection() ) { parseContext.collectUnqualifiedCollectionRole( member.getName() );
.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,
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() ); } }
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; }
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 )
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;
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() );
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(); } }
public String getPropertyName() throws MappingException { return property.getName(); }