Refine search
AtomicInteger index, Property referencedProperty ) { Property property = new Property(); property.setName( referencedProperty.getName() ); property.setPersistentClass( component.getOwner() ); property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() ); SimpleValue value = new SimpleValue( buildingContext, component.getTable() ); property.setValue( value ); final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue(); value.setTypeName( referencedValue.getTypeName() ); value.setTypeParameters( referencedValue.getTypeParameters() ); final Iterator<Selectable> columns = referencedValue.getColumnIterator(); ); final String columnName = joinColumn == null || joinColumn.isNameDeferred() ? "tata_" + column.getName() : joinColumn .getName(); value.addColumn( new Column( columnName ) ); if ( joinColumn != null ) { applyComponentColumnSizeValueToJoinColumn( column, joinColumn );
if ( generator != null ) { String generatorName = generator.getStrategy(); Properties params = new Properties(); if ( generatorDef != null ) { generatorName = generatorDef.getStrategy(); params.putAll( generatorDef.getParameters() ); identifierValue.setIdentifierGeneratorStrategy( generatorName ); params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, objectNameNormalizer); params.putAll( generator.getParameters() ); identifierValue.setIdentifierGeneratorProperties( params ); identifierValue.getTable().setIdentifierValue( identifierValue ); identifierValue.setNullValue( unsavedValue ); if ( "assigned".equals( identifierValue.getIdentifierGeneratorStrategy() ) ) { identifierValue.setNullValue( "undefined" ); identifierValue.setNullValue( null );
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator(); Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName ); referencedEntityColumns = referencedProperty.getColumnIterator(); associatedClass.getTable().getName(), element.getColumnIterator(), referencedEntityColumns fromAndWhere = getFromAndWhereFormula( targetPropertyPersistentClass.getTable() .getQualifiedTableName() .toString(), element.getColumnIterator(), targetValue = new SimpleValue( getBuildingContext(), collection.getCollectionTable() ); targetValue.copyTypeFrom( sourceValue ); Iterator columns = sourceValue.getColumnIterator(); Random random = new Random(); while ( columns.hasNext() ) { String formulaString; if ( current instanceof Column ) { formulaString = ( (Column) current ).getQuotedName(); targetValue.addFormula( formula );
public void copyTypeFrom( SimpleValue sourceValue ) { setTypeName( sourceValue.getTypeName() ); setTypeParameters( sourceValue.getTypeParameters() ); type = sourceValue.type; attributeConverterDescriptor = sourceValue.attributeConverterDescriptor; }
public void linkWithValue(SimpleValue value) { if ( formula != null ) { value.addFormula( formula ); } else { getMappingColumn().setValue( value ); value.addColumn( getMappingColumn(), insertable, updatable ); value.getTable().addColumn( getMappingColumn() ); addColumnBinding( value ); table = value.getTable(); } }
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 ); } }
private void manageIncrementGenerator(Mappings mappings, Table tab, SimpleValue id, String entityName) { id.setIdentifierGeneratorStrategy("increment"); Properties params = new Properties(); params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); params.setProperty(PersistentIdentifierGenerator.SCHEMA, quoteIdentifier(tab.getSchema())); params.put(IncrementGenerator.ENTITY_NAME, entityName); id.setIdentifierGeneratorProperties(params); id.setNullValue(null); }
log.debugf( "#makeIdGenerator(%s, %s, %s, %s, ...)", id, idXProperty, generatorType, generatorName ); Table table = id.getTable(); table.setIdentifierValue( id ); id.setIdentifierGeneratorStrategy( generatorType ); Properties params = new Properties(); params.setProperty( PersistentIdentifierGenerator.TABLE, table.getName() ); params.put( PersistentIdentifierGenerator.CATALOG, implicitCatalogName ); if ( id.getColumnSpan() == 1 ) { params.setProperty( PersistentIdentifierGenerator.PK, ( (org.hibernate.mapping.Column) id.getColumnIterator().next() ).getName() ); || identifierGeneratorStrategy.equals( MultipleHiLoPerTableGenerator.class.getName() ); if ( generatorType == null || !avoidOverriding ) { id.setIdentifierGeneratorStrategy( identifierGeneratorStrategy ); id.setNullValue( "undefined" ); id.setIdentifierGeneratorProperties( params );
private static void bindSimpleValueType(Element node, SimpleValue simpleValue, Mappings mappings) throws MappingException { String typeName = null; Properties parameters = new Properties(); Attribute typeNode = node.attribute( "type" ); if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any if ( typeNode != null ) typeName = typeNode.getValue(); Element typeChild = node.element( "type" ); if ( typeName == null && typeChild != null ) { typeName = typeChild.attribute( "name" ).getValue(); Iterator typeParameters = typeChild.elementIterator( "param" ); while ( typeParameters.hasNext() ) { Element paramElement = (Element) typeParameters.next(); parameters.setProperty( paramElement.attributeValue( "name" ), paramElement .getTextTrim() ); } } TypeDef typeDef = mappings.getTypeDef( typeName ); if ( typeDef != null ) { typeName = typeDef.getTypeClass(); // parameters on the property mapping should // override parameters in the typedef Properties allParameters = new Properties(); allParameters.putAll( typeDef.getParameters() ); allParameters.putAll( parameters ); parameters = allParameters; } if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters ); if ( typeName != null ) simpleValue.setTypeName( typeName ); }
private void updatePrimaryKey(RootClass rc, PrimaryKeyInfo pki) { SimpleValue idValue = (SimpleValue) rc.getIdentifierProperty().getValue(); Properties defaultStrategyProperties = new Properties(); Property constrainedOneToOne = getConstrainedOneToOne(rc); if(constrainedOneToOne!=null) { if(pki.suggestedStrategy==null) { idValue.setIdentifierGeneratorStrategy("foreign"); } if(pki.suggestedProperties==null) { defaultStrategyProperties.setProperty("property", constrainedOneToOne.getName()); idValue.setIdentifierGeneratorProperties(defaultStrategyProperties); } } }
SimpleValue id = new SimpleValue(mappings, entity.getTable()); Properties params = new Properties(); entity.setIdentifier(id); id.setIdentifierGeneratorStrategy("native"); } else { id.setIdentifierGeneratorStrategy(mappedId.getGenerator()); params.putAll(mappedId.getParams()); if ("assigned".equals(mappedId.getGenerator())) { id.setNullValue("undefined"); params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); params.setProperty(PersistentIdentifierGenerator.CATALOG, mappings.getCatalogName()); id.setIdentifierGeneratorProperties(params); Property prop = new Property(); prop.setValue(id); id.getTable().setIdentifierValue(id);
if ( generator != null ) { String generatorName = generator.getStrategy(); Properties params = new Properties(); if ( generatorDef != null ) { generatorName = generatorDef.getStrategy(); params.putAll( generatorDef.getParameters() ); identifierValue.setIdentifierGeneratorStrategy( generatorName ); params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, objectNameNormalizer); params.putAll( generator.getParameters() ); identifierValue.setIdentifierGeneratorProperties( params ); identifierValue.getMappedTable().setIdentifierValue( identifierValue ); identifierValue.setNullValue( unsavedValue ); if ( "assigned".equals( identifierValue.getIdentifierGeneratorStrategy() ) ) { identifierValue.setNullValue( "undefined" ); identifierValue.setNullValue( null );
propertyName ); simpleValue.setJpaAttributeConverterDescriptor( attributeConverterDescriptor ); simpleValue.setTypeParameters( typeDef.getParametersAsProperties() ); simpleValue.setTypeParameters( typeParameters ); simpleValue.setTypeName( type ); simpleValue.setTypeUsingReflection( persistentClassName, propertyName ); if ( !simpleValue.isTypeSpecified() && isVersion() ) { simpleValue.setTypeName( "integer" ); simpleValue.setTypeName( timeStampVersionType ); if ( simpleValue.getTypeName() != null && simpleValue.getTypeName().length() > 0 && simpleValue.getMetadata().getTypeResolver().basic( simpleValue.getTypeName() ) == null ) { try { Class typeClass = buildingContext.getBootstrapContext().getClassLoaderAccess().classForName( simpleValue.getTypeName() ); Properties parameters = simpleValue.getTypeParameters(); if ( parameters == null ) { parameters = new Properties(); parameters.put( DynamicParameterizedType.PROPERTY, xproperty.getName() ); parameters.put( DynamicParameterizedType.ACCESS_TYPE, accessType.getType() ); simpleValue.setTypeParameters( parameters );
SimpleValue sv = (SimpleValue) classMapping.getIdentifier(); Assert.assertEquals("CustomOID", ((Component)sv).getComponentClassName()); Assert.assertEquals(2,classMapping.getIdentifierProperty().getColumnSpan()); Property identifierProperty = classMapping.getIdentifierProperty(); Assert.assertEquals("customOrderId", identifierProperty.getName()); sv = (SimpleValue) classMapping.getIdentifier(); Assert.assertEquals("sequence", sv.getIdentifierGeneratorStrategy()); // will fail if default schema is not set since then there is no match in the override binder Assert.assertNotNull(sv.getIdentifierGeneratorProperties()); Assert.assertEquals("seq_table", sv.getIdentifierGeneratorProperties().getProperty("table"));
Metadata metadata = database.getMetadata(); String hibernateType = hibernateColumn.getSqlType(dialect, metadata); Matcher defaultValueMatcher = Pattern.compile("(?i) DEFAULT\\s+(.*)").matcher(hibernateType); if (defaultValueMatcher.find()) { DataType dataType = toDataType(hibernateType, hibernateColumn.getSqlTypeCode()); if (dataType == null) { throw new DatabaseException("Unable to find column data type for column " + hibernateColumn.getName()); DataType parseType; if (DataTypeFactory.getInstance().from(dataType, database) instanceof UnknownType) { parseType = new DataType(((SimpleValue) hibernateColumn.getValue()).getTypeName()); } else { parseType = dataType; column.setCertainDataType(false); org.hibernate.mapping.PrimaryKey hibernatePrimaryKey = hibernateTable.getPrimaryKey(); if (hibernatePrimaryKey != null) { boolean isPrimaryKeyColumn = false; identifierGeneratorStrategy = hibernateColumn.getValue().isSimpleValue() ? ((SimpleValue) hibernateColumn.getValue()).getIdentifierGeneratorStrategy() : null; Properties prop = ((SimpleValue) hibernateColumn.getValue()).getIdentifierGeneratorProperties(); if (prop.get("sequence_name") == null) column.setAutoIncrementInformation(new Column.AutoIncrementInformation());
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" ); } }
SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() ); key.setCascadeDeleteEnabled( false ); Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator(); while ( mappedByColumns.hasNext() ) { Column column = (Column) mappedByColumns.next(); Column copy = new Column(); copy.setLength( column.getLength() ); copy.setScale( column.getScale() ); copy.setValue( key ); copy.setComment( column.getComment() ); copy.setDefaultValue( column.getDefaultValue() ); key.addColumn( copy ); persistentClass.addJoin( join ); return join;
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator(); Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName ); referencedEntityColumns = referencedProperty.getColumnIterator(); .append( associatedClass.getTable().getName() ) Column colColumn = (Column) collectionTableColumns.next(); Column refColumn = (Column) referencedEntityColumns.next(); fromAndWhereSb.append( alias ).append( '.' ).append( refColumn.getQuotedName() ) .append( '=' ).append( colColumn.getQuotedName() ).append( " and " ); targetValue = new SimpleValue( collection.getCollectionTable() ); targetValue.setTypeName( sourceValue.getTypeName() ); targetValue.setTypeParameters( sourceValue.getTypeParameters() ); Iterator columns = sourceValue.getColumnIterator(); Random random = new Random(); while ( columns.hasNext() ) { String formulaString; if ( current instanceof Column ) { formulaString = ( (Column) current ).getQuotedName(); targetValue.addFormula( formula );
boolean areColumnsNullableByDefault, ColumnNamingDelegate columnNamingDelegate) { Table table = simpleValue.getTable(); final Column column = new Column(); column.setValue( simpleValue ); database.getJdbcEnvironment() ); column.setName( physicalName.render( database.getDialect() ) ); table.addColumn( column ); sourceDocument.getMetadataCollector().addColumnNameBinding( table, column.setCustomWrite( columnSource.getWriteFragment() ); simpleValue.addColumn( column ); table.getOrCreateIndex( name ).addColumn( column ); table.getOrCreateUniqueKey( name ).addColumn( column );
Table table = new Table().setName(hibernateTable.getName()); PrimaryKey primaryKey = null; int pkColumnPosition = 0; Iterator columnIterator = hibernateTable.getColumnIterator(); while (columnIterator.hasNext()) { org.hibernate.mapping.Column hibernateColumn = (org.hibernate.mapping.Column) columnIterator.next(); Column column = new Column(); column.setName(hibernateColumn.getName()); String hibernateType = hibernateColumn.getSqlType(dialect, mapping); DataType dataType = toDataType(hibernateType, hibernateColumn.getSqlTypeCode()); if (dataType == null) { throw new DatabaseException("Unable to find column data type for column " + hibernateColumn.getName()); column.setCertainDataType(false); org.hibernate.mapping.PrimaryKey hibernatePrimaryKey = hibernateTable.getPrimaryKey(); if (hibernatePrimaryKey != null) { boolean isPrimaryKeyColumn = false; String identifierGeneratorStrategy = hibernateColumn.getValue().isSimpleValue() ? ((SimpleValue) hibernateColumn.getValue()).getIdentifierGeneratorStrategy() : null; if (("native".equals(identifierGeneratorStrategy) || "identity".equals(identifierGeneratorStrategy)) && dialect.getNativeIdentifierGeneratorClass().equals(IdentityGenerator.class)) {