protected ServiceRegistry resolveServiceRegistry() { if ( getPersistentClass() != null ) { return getPersistentClass().getServiceRegistry(); } if ( getValue() != null ) { return getValue().getServiceRegistry(); } throw new HibernateException( "Could not resolve ServiceRegistry" ); }
private static Getter getGetter(Property mappingProperty) { if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) { return null; } final PropertyAccessStrategyResolver propertyAccessStrategyResolver = mappingProperty.getPersistentClass().getServiceRegistry().getService( PropertyAccessStrategyResolver.class ); final PropertyAccessStrategy propertyAccessStrategy = propertyAccessStrategyResolver.resolvePropertyAccessStrategy( mappingProperty.getClass(), mappingProperty.getPropertyAccessorName(), EntityMode.POJO ); final PropertyAccess propertyAccess = propertyAccessStrategy.buildPropertyAccess( mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName() ); return propertyAccess.getGetter(); }
@SuppressWarnings("unchecked") private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) { boolean hasNotNull = false; if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) { // single table inheritance should not be forced to null due to shared state if ( !( property.getPersistentClass() instanceof SingleTableSubclass ) ) { //composite should not add not-null on all columns if ( !property.isComposite() ) { final Iterator<Selectable> itr = property.getColumnIterator(); while ( itr.hasNext() ) { final Selectable selectable = itr.next(); if ( Column.class.isInstance( selectable ) ) { Column.class.cast( selectable ).setNullable( false ); } else { LOG.debugf( "@NotNull was applied to attribute [%s] which is defined (at least partially) " + "by formula(s); formula portions will be skipped", property.getName() ); } } } } hasNotNull = true; } return hasNotNull; }
propertySubclassNames[i] = prop.getPersistentClass().getEntityName(); String[] colNames = new String[span]; String[] colAliases = new String[span]; Property prop = (Property) iter.next(); names.add( prop.getName() ); classes.add( prop.getPersistentClass().getEntityName() ); boolean isDefinedBySubclass = !thisClassProperties.contains( prop ); definedBySubclass.add( Boolean.valueOf( isDefinedBySubclass ) );
if ( key == null ) key = property.getPersistentClass().getIdentifier(); mappedByColumns = key.getColumnIterator();
public static InDatabaseValueGenerationStrategyImpl create( SessionFactoryImplementor sessionFactoryImplementor, Property mappingProperty, ValueGeneration valueGeneration) { final int numberOfMappedColumns = mappingProperty.getType().getColumnSpan( sessionFactoryImplementor ); if ( numberOfMappedColumns == 1 ) { return new InDatabaseValueGenerationStrategyImpl( valueGeneration.getGenerationTiming(), valueGeneration.referenceColumnInSql(), new String[] { valueGeneration.getDatabaseGeneratedReferencedColumnValue() } ); } else { if ( valueGeneration.getDatabaseGeneratedReferencedColumnValue() != null ) { LOG.debugf( "Value generator specified column value in reference to multi-column attribute [%s -> %s]; ignoring", mappingProperty.getPersistentClass(), mappingProperty.getName() ); } return new InDatabaseValueGenerationStrategyImpl( valueGeneration.getGenerationTiming(), valueGeneration.referenceColumnInSql(), new String[numberOfMappedColumns] ); } }
prop.getPersistentClass().getEntityName() + '.' + prop.getName(), join );
newProperty.setPersistentClass( current.getPersistentClass() ); newProperty.setPropertyAccessorName( current.getPropertyAccessorName() ); newProperty.setSelectable( current.isSelectable() );
/** * create a property copy reusing the same value */ public static Property shallowCopy(Property property) { Property clone = new Property(); clone.setCascade( property.getCascade() ); clone.setInsertable( property.isInsertable() ); clone.setLazy( property.isLazy() ); clone.setName( property.getName() ); clone.setNaturalIdentifier( property.isNaturalIdentifier() ); clone.setOptimisticLocked( property.isOptimisticLocked() ); clone.setOptional( property.isOptional() ); clone.setPersistentClass( property.getPersistentClass() ); clone.setPropertyAccessorName( property.getPropertyAccessorName() ); clone.setSelectable( property.isSelectable() ); clone.setUpdateable( property.isUpdateable() ); clone.setValue( property.getValue() ); return clone; }
mapProperty.getPersistentClass() : associatedClass; Value indexValue = createFormulatedValue(
private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) { boolean hasNotNull = false; if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) { if ( ! ( property.getPersistentClass() instanceof SingleTableSubclass ) ) { //single table should not be forced to null if ( !property.isComposite() ) { //composite should not add not-null on all columns @SuppressWarnings( "unchecked" ) Iterator<Column> iter = (Iterator<Column>) property.getColumnIterator(); while ( iter.hasNext() ) { iter.next().setNullable( false ); hasNotNull = true; } } } hasNotNull = true; } return hasNotNull; }
getGetter( property ), (VersionType) property.getType(), getConstructor( property.getPersistentClass() ) );
); PersistentClass pc = p.getPersistentClass(); String table; if ( pc == null ) {
newProperty.setPersistentClass( current.getPersistentClass() ); newProperty.setPropertyAccessorName( current.getPropertyAccessorName() ); newProperty.setSelectable( current.isSelectable() );
if ( key == null ) key = property.getPersistentClass().getIdentifier(); mappedByColumns = key.getColumnIterator();
@Override protected void visitProperty(PersistentClass clazz, Property property, IssueCollector collector) { if(property.getName().equals("id")) { if (property != property.getPersistentClass().getIdentifierProperty()) { collector.reportIssue(new Issue("ID_SHADOWED", Issue.LOW_PRIORITY, property.getPersistentClass().getEntityName() + " has a normal property named 'id'. This can cause issues since HQL queries will always interpret 'id' as the identifier and not the concrete property")); } } } }
/** * create a property copy reusing the same value */ public static Property shallowCopy(Property property) { Property clone = new Property(); clone.setCascade( property.getCascade() ); clone.setInsertable( property.isInsertable() ); clone.setLazy( property.isLazy() ); clone.setName( property.getName() ); clone.setNodeName( property.getNodeName() ); clone.setNaturalIdentifier( property.isNaturalIdentifier() ); clone.setOptimisticLocked( property.isOptimisticLocked() ); clone.setOptional( property.isOptional() ); clone.setPersistentClass( property.getPersistentClass() ); clone.setPropertyAccessorName( property.getPropertyAccessorName() ); clone.setSelectable( property.isSelectable() ); clone.setUpdateable( property.isUpdateable() ); clone.setValue( property.getValue() ); return clone; }
private static Getter getGetter(Property mappingProperty) { if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) { return null; } PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO ); return pa.getGetter( mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName() ); }
private static Getter getGetter(Property mappingProperty) { if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) { return null; } PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO ); return pa.getGetter( mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName() ); }
private static Getter getGetter(Property mappingProperty) { if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) { return null; } PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO ); return pa.getGetter( mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName() ); }