public void copyTypeFrom( SimpleValue sourceValue ) { setTypeName( sourceValue.getTypeName() ); setTypeParameters( sourceValue.getTypeParameters() ); type = sourceValue.type; attributeConverterDescriptor = sourceValue.attributeConverterDescriptor; }
private static void bindSimpleValueType( MappingDocument mappingDocument, HibernateTypeSource typeSource, SimpleValue simpleValue) { if ( mappingDocument.getBuildingOptions().useNationalizedCharacterData() ) { simpleValue.makeNationalized(); } final TypeResolution typeResolution = resolveType( mappingDocument, typeSource ); if ( typeResolution == null ) { // no explicit type info was found return; } if ( CollectionHelper.isNotEmpty( typeResolution.parameters ) ) { simpleValue.setTypeParameters( typeResolution.parameters ); } if ( typeResolution.typeName != null ) { simpleValue.setTypeName( typeResolution.typeName ); } }
simpleValue.setTypeName( type ); simpleValue.setTypeName( "integer" ); simpleValue.setTypeName( timeStampVersionType );
property.setValue( value ); final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue(); value.setTypeName( referencedValue.getTypeName() ); value.setTypeParameters( referencedValue.getTypeParameters() ); final Iterator<Selectable> columns = referencedValue.getColumnIterator();
private static void bindDiscriminatorColumnToRootPersistentClass( RootClass rootClass, Ejb3DiscriminatorColumn discriminatorColumn, Map<String, Join> secondaryTables, PropertyHolder propertyHolder, MetadataBuildingContext context) { if ( rootClass.getDiscriminator() == null ) { if ( discriminatorColumn == null ) { throw new AssertionFailure( "discriminator column should have been built" ); } discriminatorColumn.setJoins( secondaryTables ); discriminatorColumn.setPropertyHolder( propertyHolder ); SimpleValue discriminatorColumnBinding = new SimpleValue( context, rootClass.getTable() ); rootClass.setDiscriminator( discriminatorColumnBinding ); discriminatorColumn.linkWithValue( discriminatorColumnBinding ); discriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() ); rootClass.setPolymorphic( true ); if ( LOG.isTraceEnabled() ) { LOG.tracev( "Setting discriminator for entity {0}", rootClass.getEntityName() ); } } }
public void fillSimpleValue() { log.debug( "setting SimpleValue typeName for {}", propertyName ); String type = BinderHelper.isDefault( explicitType ) ? returnedClassName : explicitType; org.hibernate.mapping.TypeDef typeDef = mappings.getTypeDef( type ); if ( typeDef != null ) { type = typeDef.getTypeClass(); simpleValue.setTypeParameters( typeDef.getParameters() ); } if ( typeParameters != null && typeParameters.size() != 0 ) { //explicit type params takes precedence over type def params simpleValue.setTypeParameters( typeParameters ); } simpleValue.setTypeName( type ); if ( persistentClassName != null ) { simpleValue.setTypeUsingReflection( persistentClassName, propertyName ); } if ( !simpleValue.isTypeSpecified() && isVersion()) { simpleValue.setTypeName( "integer" ); } }
private static void bindDiscriminatorToPersistentClass( RootClass rootClass, Ejb3DiscriminatorColumn discriminatorColumn, Map<String, Join> secondaryTables, PropertyHolder propertyHolder ) { if ( rootClass.getDiscriminator() == null ) { if ( discriminatorColumn == null ) { throw new AssertionFailure( "discriminator column should have been built" ); } discriminatorColumn.setJoins( secondaryTables ); discriminatorColumn.setPropertyHolder( propertyHolder ); SimpleValue discrim = new SimpleValue( rootClass.getTable() ); rootClass.setDiscriminator( discrim ); discriminatorColumn.linkWithValue( discrim ); discrim.setTypeName( discriminatorColumn.getDiscriminatorTypeName() ); rootClass.setPolymorphic( true ); log.trace( "Setting discriminator for entity {}", rootClass.getEntityName() ); } }
property.setValue( value ); final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue(); value.setTypeName( referencedValue.getTypeName() ); value.setTypeParameters( referencedValue.getTypeParameters() ); final Iterator<Column> columns = referencedValue.getColumnIterator();
targetValue.setTypeName( sourceValue.getTypeName() ); targetValue.setTypeParameters( sourceValue.getTypeParameters() );
private SimpleValue bindColumnToSimpleValue(Table table, Column column, Mapping mapping, boolean generatedIdentifier) { SimpleValue value = new SimpleValue(mdbc, table); value.addColumn(column); value.setTypeName(guessAndAlignType(table, column, mapping, generatedIdentifier)); return value; }
private SimpleValue bindColumnToSimpleValue(Table table, Column column, Mapping mapping, boolean generatedIdentifier) { SimpleValue value = new SimpleValue((MetadataImplementor)metadata, table); value.addColumn(column); value.setTypeName(guessAndAlignType(table, column, mapping, generatedIdentifier)); return value; }
private static void setTypeForPropertyConfig(GrailsDomainClassProperty grailsProp, SimpleValue simpleValue, PropertyConfig config) { final String typeName = getTypeName(grailsProp, getPropertyConfig(grailsProp), getMapping(grailsProp.getDomainClass())); if (typeName == null) { simpleValue.setTypeName(grailsProp.getType().getName()); } else { simpleValue.setTypeName(typeName); if (config != null) { simpleValue.setTypeParameters(config.getTypeParams()); } } }
protected void setTypeForPropertyConfig(PersistentProperty grailsProp, SimpleValue simpleValue, PropertyConfig config) { final String typeName = getTypeName(grailsProp, getPropertyConfig(grailsProp), getMapping(grailsProp.getOwner())); if (typeName == null) { simpleValue.setTypeName(grailsProp.getType().getName()); } else { simpleValue.setTypeName(typeName); if (config != null) { simpleValue.setTypeParameters(config.getTypeParams()); } } }
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode, Mappings mappings) { SimpleValue discrim = new SimpleValue( table ); entity.setDiscriminator( discrim ); bindSimpleValue( subnode, discrim, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings ); if ( !discrim.isTypeSpecified() ) { discrim.setTypeName( "string" ); // ( (Column) discrim.getColumnIterator().next() ).setType(type); } entity.setPolymorphic( true ); if ( "true".equals( subnode.attributeValue( "force" ) ) ) entity.setForceDiscriminator( true ); if ( "false".equals( subnode.attributeValue( "insert" ) ) ) entity.setDiscriminatorInsertable( false ); }
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode, Mappings mappings) { SimpleValue discrim = new SimpleValue( table ); entity.setDiscriminator( discrim ); bindSimpleValue( subnode, discrim, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings ); if ( !discrim.isTypeSpecified() ) { discrim.setTypeName( "string" ); // ( (Column) discrim.getColumnIterator().next() ).setType(type); } entity.setPolymorphic( true ); if ( "true".equals( subnode.attributeValue( "force" ) ) ) entity.setForceDiscriminator( true ); if ( "false".equals( subnode.attributeValue( "insert" ) ) ) entity.setDiscriminatorInsertable( false ); }
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode, Mappings mappings) { SimpleValue discrim = new SimpleValue( mappings, table ); entity.setDiscriminator( discrim ); bindSimpleValue( subnode, discrim, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings ); if ( !discrim.isTypeSpecified() ) { discrim.setTypeName( "string" ); // ( (Column) discrim.getColumnIterator().next() ).setType(type); } entity.setPolymorphic( true ); final String explicitForceValue = subnode.attributeValue( "force" ); boolean forceDiscriminatorInSelects = explicitForceValue == null ? mappings.forceDiscriminatorInSelectsByDefault() : "true".equals( explicitForceValue ); entity.setForceDiscriminator( forceDiscriminatorInSelects ); if ( "false".equals( subnode.attributeValue( "insert" ) ) ) { entity.setDiscriminatorInsertable( false ); } }
private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings, String name, RootClass entity, java.util.Map inheritedMetas) { String propertyName = subnode.attributeValue( "name" ); SimpleValue val = new SimpleValue( table ); bindSimpleValue( subnode, val, false, propertyName, mappings ); if ( !val.isTypeSpecified() ) { val.setTypeName( "version".equals( name ) ? "integer" : "timestamp" ); } Property prop = new Property(); prop.setValue( val ); bindProperty( subnode, prop, mappings, inheritedMetas ); makeVersion( subnode, val ); entity.setVersion( prop ); entity.addProperty( prop ); }
public SimpleValue fillSimpleValue(SimpleValue simpleValue) { String type = BinderHelper.isDefault( explicitType ) ? returnedClassName : explicitType; org.hibernate.mapping.TypeDef typeDef = mappings.getTypeDef( type ); if ( typeDef != null ) { type = typeDef.getTypeClass(); simpleValue.setTypeParameters( typeDef.getParameters() ); } if ( typeParameters != null && typeParameters.size() != 0 ) { //explicit type params takes precedence over type def params simpleValue.setTypeParameters( typeParameters ); } simpleValue.setTypeName( type ); if ( persistentClassName != null ) { simpleValue.setTypeUsingReflection( persistentClassName, propertyName ); } for ( Ejb3Column column : columns ) { column.linkWithValue( simpleValue ); } return simpleValue; } }
/** * Binds a value for the specified parameters to the meta model. * * @param type The type of the property * @param simpleValue The simple value instance * @param nullable Whether it is nullable * @param columnName The property name * @param mappings The mappings */ protected void bindSimpleValue(String type, SimpleValue simpleValue, boolean nullable, String columnName, Mappings mappings) { simpleValue.setTypeName(type); Table t = simpleValue.getTable(); Column column = new Column(); column.setNullable(nullable); column.setValue(simpleValue); column.setName(columnName); if (t != null) t.addColumn(column); simpleValue.addColumn(column); }
private static void bindDiscriminatorToPersistentClass( RootClass rootClass, Ejb3DiscriminatorColumn discriminatorColumn, Map<String, Join> secondaryTables, PropertyHolder propertyHolder, Mappings mappings) { if ( rootClass.getDiscriminator() == null ) { if ( discriminatorColumn == null ) { throw new AssertionFailure( "discriminator column should have been built" ); } discriminatorColumn.setJoins( secondaryTables ); discriminatorColumn.setPropertyHolder( propertyHolder ); SimpleValue discrim = new SimpleValue( mappings, rootClass.getTable() ); rootClass.setDiscriminator( discrim ); discriminatorColumn.linkWithValue( discrim ); discrim.setTypeName( discriminatorColumn.getDiscriminatorTypeName() ); rootClass.setPolymorphic( true ); if ( LOG.isTraceEnabled() ) { LOG.tracev( "Setting discriminator for entity {0}", rootClass.getEntityName() ); } } }