org.hibernate.mapping.Component Java Examples
The following examples show how to use
org.hibernate.mapping.Component.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValueVisitorTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void testProperCallbacks() { ValueVisitor vv = new ValueVisitorValidator(); new Any(new Table()).accept(vv); new Array(new RootClass()).accept(vv); new Bag(new RootClass()).accept(vv); new Component(new RootClass()).accept(vv); new DependantValue(null,null).accept(vv); new IdentifierBag(null).accept(vv); new List(null).accept(vv); new ManyToOne(null).accept(vv); new Map(null).accept(vv); new OneToMany(null).accept(vv); new OneToOne(null, new RootClass() ).accept(vv); new PrimitiveArray(null).accept(vv); new Set(null).accept(vv); new SimpleValue().accept(vv); }
Example #2
Source File: AnnotationBinder.java From lams with GNU General Public License v2.0 | 6 votes |
public static Component createComponent( PropertyHolder propertyHolder, PropertyData inferredData, boolean isComponentEmbedded, boolean isIdentifierMapper, MetadataBuildingContext context) { Component comp = new Component( context, propertyHolder.getPersistentClass() ); comp.setEmbedded( isComponentEmbedded ); //yuk comp.setTable( propertyHolder.getTable() ); //FIXME shouldn't identifier mapper use getClassOrElementName? Need to be checked. if ( isIdentifierMapper || ( isComponentEmbedded && inferredData.getPropertyName() == null ) ) { comp.setComponentClassName( comp.getOwner().getClassName() ); } else { comp.setComponentClassName( inferredData.getClassOrElementName() ); } return comp; }
Example #3
Source File: AnnotationBinder.java From lams with GNU General Public License v2.0 | 6 votes |
public static Component fillComponent( PropertyHolder propertyHolder, PropertyData inferredData, AccessType propertyAccessor, boolean isNullable, EntityBinder entityBinder, boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass, MetadataBuildingContext buildingContext, Map<XClass, InheritanceState> inheritanceStatePerClass) { return fillComponent( propertyHolder, inferredData, null, propertyAccessor, isNullable, entityBinder, isComponentEmbedded, isIdentifierMapper, inSecondPass, buildingContext, inheritanceStatePerClass ); }
Example #4
Source File: ViewBuilder.java From teiid-spring-boot with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") String propertyName(Iterator<org.hibernate.mapping.Property> it, org.hibernate.mapping.Property identifierProperty, String colName) { if (identifierProperty != null && propertyMatches(identifierProperty, colName)) { return identifierProperty.getName(); } while (it.hasNext()) { org.hibernate.mapping.Property property = it.next(); if (propertyMatches(property, colName)) { if (property.isComposite()) { Component comp = (Component) property.getValue(); Iterator<org.hibernate.mapping.Property> compIt = comp.getPropertyIterator(); return propertyName(compIt, null, colName); } else { return property.getName(); } } } return null; }
Example #5
Source File: AbstractComponentTuplizer.java From lams with GNU General Public License v2.0 | 6 votes |
protected AbstractComponentTuplizer(Component component) { setComponentClass( component ); propertySpan = component.getPropertySpan(); getters = new Getter[propertySpan]; setters = new Setter[propertySpan]; Iterator iter = component.getPropertyIterator(); boolean foundCustomAccessor=false; int i = 0; while ( iter.hasNext() ) { Property prop = ( Property ) iter.next(); getters[i] = buildGetter( component, prop ); setters[i] = buildSetter( component, prop ); if ( !prop.isBasicPropertyAccessor() ) { foundCustomAccessor = true; } i++; } hasCustomAccessors = foundCustomAccessor; instantiator = buildInstantiator( component ); }
Example #6
Source File: ModelBinder.java From lams with GNU General Public License v2.0 | 6 votes |
private void bindComponent( MappingDocument sourceDocument, EmbeddableSource embeddableSource, Component component, String containingClassName, String propertyName, String xmlNodeName, boolean isVirtual) { final String fullRole = embeddableSource.getAttributeRoleBase().getFullPath(); final String explicitComponentClassName = extractExplicitComponentClassName( embeddableSource ); bindComponent( sourceDocument, fullRole, embeddableSource, component, explicitComponentClassName, containingClassName, propertyName, isVirtual, embeddableSource.isDynamic(), xmlNodeName ); }
Example #7
Source File: PojoInstantiator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) { this.mappedClass = component.getComponentClass(); this.optimizer = optimizer; this.proxyInterface = null; this.embeddedIdentifier = false; try { constructor = ReflectHelper.getDefaultConstructor(mappedClass); } catch ( PropertyNotFoundException pnfe ) { log.info( "no default (no-argument) constructor for class: " + mappedClass.getName() + " (class must be instantiated by Interceptor)" ); constructor = null; } }
Example #8
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void bindComposite(Element node, Component component, String path, boolean isNullable, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { bindComponent( node, component, null, null, path, isNullable, false, mappings, inheritedMetas, false ); }
Example #9
Source File: ComponentMetamodel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public ComponentMetamodel(Component component) { // this.sessionFactory = sessionFactory; this.role = component.getRoleName(); this.isKey = component.isKey(); propertySpan = component.getPropertySpan(); properties = new StandardProperty[propertySpan]; Iterator itr = component.getPropertyIterator(); int i = 0; while ( itr.hasNext() ) { Property property = ( Property ) itr.next(); properties[i] = PropertyFactory.buildStandardProperty( property, false ); propertyIndexes.put( property.getName(), new Integer( i ) ); i++; } tuplizerMapping = new ComponentEntityModeToTuplizerMapping( component ); }
Example #10
Source File: ComponentTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) { super.afterConfigurationBuilt( mappings, dialect ); // Oracle and Postgres do not have year() functions, so we need to // redefine the 'User.person.yob' formula // // consider temporary until we add the capability to define // mapping foprmulas which can use dialect-registered functions... PersistentClass user = mappings.getClass( User.class.getName() ); org.hibernate.mapping.Property personProperty = user.getProperty( "person" ); Component component = ( Component ) personProperty.getValue(); Formula f = ( Formula ) component.getProperty( "yob" ).getValue().getColumnIterator().next(); SQLFunction yearFunction = ( SQLFunction ) dialect.getFunctions().get( "year" ); if ( yearFunction == null ) { // the dialect not know to support a year() function, so rely on the // ANSI SQL extract function f.setFormula( "extract( year from dob )"); } else { List args = new ArrayList(); args.add( "dob" ); f.setFormula( yearFunction.render( args, null ) ); } }
Example #11
Source File: ClassPropertyHolder.java From lams with GNU General Public License v2.0 | 6 votes |
public void addProperty(Property prop, XClass declaringClass) { if ( prop.getValue() instanceof Component ) { //TODO handle quote and non quote table comparison String tableName = prop.getValue().getTable().getName(); if ( getJoinsPerRealTableName().containsKey( tableName ) ) { final Join join = getJoinsPerRealTableName().get( tableName ); addPropertyToJoin( prop, declaringClass, join ); } else { addPropertyToPersistentClass( prop, declaringClass ); } } else { addPropertyToPersistentClass( prop, declaringClass ); } }
Example #12
Source File: EntityMetamodel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private boolean hasPartialUpdateComponentGeneration(Component component) { Iterator subProperties = component.getPropertyIterator(); while ( subProperties.hasNext() ) { Property prop = ( Property ) subProperties.next(); if ( prop.getGeneration() == PropertyGeneration.ALWAYS ) { return true; } else if ( prop.getValue() instanceof Component ) { if ( hasPartialUpdateComponentGeneration( ( Component ) prop.getValue() ) ) { return true; } } } return false; }
Example #13
Source File: ComponentPropertyHolder.java From lams with GNU General Public License v2.0 | 5 votes |
public ComponentPropertyHolder( Component component, String path, PropertyData inferredData, PropertyHolder parent, MetadataBuildingContext context) { super( path, parent, inferredData.getPropertyClass(), context ); final XProperty embeddedXProperty = inferredData.getProperty(); setCurrentProperty( embeddedXProperty ); this.component = component; this.isOrWithinEmbeddedId = parent.isOrWithinEmbeddedId() || ( embeddedXProperty != null && ( embeddedXProperty.isAnnotationPresent( Id.class ) || embeddedXProperty.isAnnotationPresent( EmbeddedId.class ) ) ); this.isWithinElementCollection = parent.isWithinElementCollection() || parent instanceof CollectionPropertyHolder; if ( embeddedXProperty != null ) { // this.virtual = false; this.embeddedAttributeName = embeddedXProperty.getName(); this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty ); } else { // could be either: // 1) virtual/dynamic component // 2) collection element/key // temp // this.virtual = true; this.embeddedAttributeName = ""; this.attributeConversionInfoMap = processAttributeConversions( inferredData.getClassOrElement() ); } }
Example #14
Source File: EntityMetamodel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private void mapPropertyToIndex(Property prop, int i) { propertyIndexes.put( prop.getName(), new Integer(i) ); if ( prop.getValue() instanceof Component ) { Iterator iter = ( (Component) prop.getValue() ).getPropertyIterator(); while ( iter.hasNext() ) { Property subprop = (Property) iter.next(); propertyIndexes.put( prop.getName() + '.' + subprop.getName(), new Integer(i) ); } } }
Example #15
Source File: ComponentEntityModeToTuplizerMapping.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private ComponentTuplizer buildComponentTuplizer(String tuplizerImpl, Component component) { try { Class implClass = ReflectHelper.classForName( tuplizerImpl ); return ( ComponentTuplizer ) implClass.getConstructor( COMPONENT_TUP_CTOR_SIG ).newInstance( new Object[] { component } ); } catch( Throwable t ) { throw new HibernateException( "Could not build tuplizer [" + tuplizerImpl + "]", t ); } }
Example #16
Source File: TypeSafeActivator.java From lams with GNU General Public License v2.0 | 5 votes |
private static void applyDDL( String prefix, PersistentClass persistentClass, Class<?> clazz, ValidatorFactory factory, Set<Class<?>> groups, boolean activateNotNull, Dialect dialect) { final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz ); //no bean level constraints can be applied, go to the properties for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) { Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() ); boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect ); if ( property.isComposite() && propertyDesc.isCascaded() ) { Class<?> componentClass = ( (Component) property.getValue() ).getComponentClass(); /* * we can apply not null if the upper component let's us activate not null * and if the property is not null. * Otherwise, all sub columns should be left nullable */ final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull; applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups, canSetNotNullOnColumns, dialect ); } //FIXME add collection of components } } }
Example #17
Source File: PojoComponentTuplizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public PojoComponentTuplizer(Component component) { super( component ); this.componentClass = component.getComponentClass(); String[] getterNames = new String[propertySpan]; String[] setterNames = new String[propertySpan]; Class[] propTypes = new Class[propertySpan]; for ( int i = 0; i < propertySpan; i++ ) { getterNames[i] = getters[i].getMethodName(); setterNames[i] = setters[i].getMethodName(); propTypes[i] = getters[i].getReturnType(); } final String parentPropertyName = component.getParentProperty(); if ( parentPropertyName == null ) { parentSetter = null; parentGetter = null; } else { PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( null ); parentSetter = pa.getSetter( componentClass, parentPropertyName ); parentGetter = pa.getGetter( componentClass, parentPropertyName ); } if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) { optimizer = null; } else { // TODO: here is why we need to make bytecode provider global :( // TODO : again, fix this after HHH-1907 is complete optimizer = Environment.getBytecodeProvider().getReflectionOptimizer( componentClass, getterNames, setterNames, propTypes ); } }
Example #18
Source File: PojoComponentTuplizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
protected Instantiator buildInstantiator(Component component) { if ( component.isEmbedded() && ReflectHelper.isAbstractClass( component.getComponentClass() ) ) { return new ProxiedInstantiator( component ); } if ( optimizer == null ) { return new PojoInstantiator( component, null ); } else { return new PojoInstantiator( component, optimizer.getInstantiationOptimizer() ); } }
Example #19
Source File: PojoComponentTuplizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public ProxiedInstantiator(Component component) { proxiedClass = component.getComponentClass(); if ( proxiedClass.isInterface() ) { factory = Environment.getBytecodeProvider() .getProxyFactoryFactory() .buildBasicProxyFactory( null, new Class[] { proxiedClass } ); } else { factory = Environment.getBytecodeProvider() .getProxyFactoryFactory() .buildBasicProxyFactory( proxiedClass, null ); } }
Example #20
Source File: ToOneFkSecondPass.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean isInPrimaryKey() { if ( entityClassName == null ) return false; final PersistentClass persistentClass = buildingContext.getMetadataCollector().getEntityBinding( entityClassName ); Property property = persistentClass.getIdentifierProperty(); if ( path == null ) { return false; } else if ( property != null) { //try explicit identifier property return path.startsWith( property.getName() + "." ); } else { //try the embedded property //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor if ( path.startsWith( "id." ) ) { KeyValue valueIdentifier = persistentClass.getIdentifier(); String localPath = path.substring( 3 ); if ( valueIdentifier instanceof Component ) { Iterator it = ( (Component) valueIdentifier ).getPropertyIterator(); while ( it.hasNext() ) { Property idProperty = (Property) it.next(); if ( localPath.startsWith( idProperty.getName() ) ) return true; } } } } return false; }
Example #21
Source File: AbstractComponentTuplizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
protected AbstractComponentTuplizer(Component component) { propertySpan = component.getPropertySpan(); getters = new Getter[propertySpan]; setters = new Setter[propertySpan]; Iterator iter = component.getPropertyIterator(); boolean foundCustomAccessor=false; int i = 0; while ( iter.hasNext() ) { Property prop = ( Property ) iter.next(); getters[i] = buildGetter( component, prop ); setters[i] = buildSetter( component, prop ); if ( !prop.isBasicPropertyAccessor() ) { foundCustomAccessor = true; } i++; } hasCustomAccessors = foundCustomAccessor; String[] getterNames = new String[propertySpan]; String[] setterNames = new String[propertySpan]; Class[] propTypes = new Class[propertySpan]; for ( int j = 0; j < propertySpan; j++ ) { getterNames[j] = getters[j].getMethodName(); setterNames[j] = setters[j].getMethodName(); propTypes[j] = getters[j].getReturnType(); } instantiator = buildInstantiator( component ); }
Example #22
Source File: EntityMetamodel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private ValueInclusion determineUpdateValueGenerationType(Property mappingProperty, StandardProperty runtimeProperty) { if ( runtimeProperty.isUpdateGenerated() ) { return ValueInclusion.FULL; } else if ( mappingProperty.getValue() instanceof Component ) { if ( hasPartialUpdateComponentGeneration( ( Component ) mappingProperty.getValue() ) ) { return ValueInclusion.PARTIAL; } } return ValueInclusion.NONE; }
Example #23
Source File: EntityMetamodel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private boolean hasPartialInsertComponentGeneration(Component component) { Iterator subProperties = component.getPropertyIterator(); while ( subProperties.hasNext() ) { Property prop = ( Property ) subProperties.next(); if ( prop.getGeneration() == PropertyGeneration.ALWAYS || prop.getGeneration() == PropertyGeneration.INSERT ) { return true; } else if ( prop.getValue() instanceof Component ) { if ( hasPartialInsertComponentGeneration( ( Component ) prop.getValue() ) ) { return true; } } } return false; }
Example #24
Source File: EntityMetamodel.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private ValueInclusion determineInsertValueGenerationType(Property mappingProperty, StandardProperty runtimeProperty) { if ( runtimeProperty.isInsertGenerated() ) { return ValueInclusion.FULL; } else if ( mappingProperty.getValue() instanceof Component ) { if ( hasPartialInsertComponentGeneration( ( Component ) mappingProperty.getValue() ) ) { return ValueInclusion.PARTIAL; } } return ValueInclusion.NONE; }
Example #25
Source File: AbstractEntityPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) { while ( propertyIterator.hasNext() ) { Property prop = ( Property ) propertyIterator.next(); String propname = path == null ? prop.getName() : path + "." + prop.getName(); if ( prop.isComposite() ) { Component component = ( Component ) prop.getValue(); Iterator compProps = component.getPropertyIterator(); internalInitSubclassPropertyAliasesMap( propname, compProps ); } else { String[] aliases = new String[prop.getColumnSpan()]; String[] cols = new String[prop.getColumnSpan()]; Iterator colIter = prop.getColumnIterator(); int l = 0; while ( colIter.hasNext() ) { Selectable thing = ( Selectable ) colIter.next(); aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
Example #26
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { String propertyName = idNode.attributeValue( "name" ); Component id = new Component( entity ); entity.setIdentifier( id ); bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas ); if ( propertyName == null ) { entity.setEmbeddedIdentifier( id.isEmbedded() ); if ( id.isEmbedded() ) { // todo : what is the implication of this? id.setDynamic( !entity.hasPojoRepresentation() ); /* * Property prop = new Property(); prop.setName("id"); * prop.setPropertyAccessorName("embedded"); prop.setValue(id); * entity.setIdentifierProperty(prop); */ } } else { Property prop = new Property(); prop.setValue( id ); bindProperty( idNode, prop, mappings, inheritedMetas ); entity.setIdentifierProperty( prop ); } makeIdentifier( idNode, id, mappings ); }
Example #27
Source File: ModelBinder.java From lams with GNU General Public License v2.0 | 5 votes |
private void prepareComponentType( MappingDocument sourceDocument, String fullRole, Component componentBinding, String explicitComponentClassName, String containingClassName, String propertyName, boolean isVirtual, boolean isDynamic) { }
Example #28
Source File: ModelBinder.java From lams with GNU General Public License v2.0 | 5 votes |
private void finishBindingCompositeIdentifier( MappingDocument sourceDocument, RootClass rootEntityDescriptor, CompositeIdentifierSource identifierSource, Component cid, String propertyName) { if ( propertyName == null ) { rootEntityDescriptor.setEmbeddedIdentifier( cid.isEmbedded() ); if ( cid.isEmbedded() ) { // todo : what is the implication of this? cid.setDynamic( !rootEntityDescriptor.hasPojoRepresentation() ); /* * Property prop = new Property(); prop.setName("id"); * prop.setPropertyAccessorName("embedded"); prop.setValue(id); * entity.setIdentifierProperty(prop); */ } } else { Property prop = new Property(); prop.setValue( cid ); bindProperty( sourceDocument, ( (IdentifierSourceAggregatedComposite) identifierSource ).getIdentifierAttributeSource(), prop ); rootEntityDescriptor.setIdentifierProperty( prop ); rootEntityDescriptor.setDeclaredIdentifierProperty( prop ); } makeIdentifier( sourceDocument, identifierSource.getIdentifierGeneratorDescriptor(), null, cid ); }
Example #29
Source File: PropertyHolderBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * build a component property holder * * @param component component to wrap * @param path component path * @param context * @return PropertyHolder */ public static PropertyHolder buildPropertyHolder( Component component, String path, PropertyData inferredData, PropertyHolder parent, MetadataBuildingContext context) { return new ComponentPropertyHolder( component, path, inferredData, parent, context ); }
Example #30
Source File: PojoComponentTuplizer.java From lams with GNU General Public License v2.0 | 5 votes |
protected Instantiator buildInstantiator(Component component) { if ( component.isEmbedded() && ReflectHelper.isAbstractClass( this.componentClass ) ) { return new ProxiedInstantiator( this.componentClass ); } if ( optimizer == null ) { return new PojoInstantiator( this.componentClass, null ); } else { return new PojoInstantiator( this.componentClass, optimizer.getInstantiationOptimizer() ); } }