org.hibernate.mapping.SimpleValue Java Examples

The following examples show how to use org.hibernate.mapping.SimpleValue. 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: ModelBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void resolveLob(final SingularAttributeSourceBasic attributeSource, SimpleValue value) {
	// Resolves whether the property is LOB based on the type attribute on the attribute property source.
	// Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares.
	if ( !value.isLob() && value.getTypeName() != null ) {
		final TypeResolver typeResolver = attributeSource.getBuildingContext().getMetadataCollector().getTypeResolver();
		final BasicType basicType = typeResolver.basic( value.getTypeName() );
		if ( basicType instanceof AbstractSingleColumnStandardBasicType ) {
			if ( isLob( ( (AbstractSingleColumnStandardBasicType) basicType ).getSqlTypeDescriptor().getSqlType(), null ) ) {
				value.makeLob();
			}
		}
	}

	// If the prior check didn't set the lob flag, this will inspect the column sql-type attribute value and
	// if this maps to CLOB/NCLOB/BLOB then the value will be marked as lob.
	if ( !value.isLob() ) {
		for ( RelationalValueSource relationalValueSource : attributeSource.getRelationalValueSources() ) {
			if ( ColumnSource.class.isInstance( relationalValueSource ) ) {
				if ( isLob( null, ( (ColumnSource) relationalValueSource ).getSqlType() ) ) {
					value.makeLob();
				}
			}
		}
	}
}
 
Example #2
Source File: ModelBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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 );
	}
}
 
Example #3
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void setFKNameIfDefined(Join join) {
	// just awful..

	org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join );
	if ( matchingTable != null && !BinderHelper.isEmptyAnnotationValue( matchingTable.foreignKey().name() ) ) {
		( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreignKey().name() );
	}
	else {
		javax.persistence.SecondaryTable jpaSecondaryTable = findMatchingSecondaryTable( join );
		if ( jpaSecondaryTable != null ) {
			if ( jpaSecondaryTable.foreignKey().value() == ConstraintMode.NO_CONSTRAINT ) {
				( (SimpleValue) join.getKey() ).setForeignKeyName( "none" );
			}
			else {
				( (SimpleValue) join.getKey() ).setForeignKeyName( StringHelper.nullIfEmpty( jpaSecondaryTable.foreignKey().name() ) );
				( (SimpleValue) join.getKey() ).setForeignKeyDefinition( StringHelper.nullIfEmpty( jpaSecondaryTable.foreignKey().foreignKeyDefinition() ) );
			}
		}
	}
}
 
Example #4
Source File: ValueVisitorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #5
Source File: RelationalObjectBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void bindColumnsAndFormulas(
		MappingDocument sourceDocument,
		List<RelationalValueSource> relationalValueSources,
		SimpleValue simpleValue,
		boolean areColumnsNullableByDefault,
		ColumnNamingDelegate columnNamingDelegate) {
	for ( RelationalValueSource relationalValueSource : relationalValueSources ) {
		if ( ColumnSource.class.isInstance( relationalValueSource ) ) {
			final ColumnSource columnSource = (ColumnSource) relationalValueSource;
			bindColumn(
					sourceDocument,
					columnSource,
					simpleValue,
					areColumnsNullableByDefault,
					columnNamingDelegate
			);
		}
		else {
			final DerivedValueSource formulaSource = (DerivedValueSource) relationalValueSource;
			simpleValue.addFormula( new Formula( formulaSource.getExpression() ) );
		}
	}
}
 
Example #6
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void bindIdentifierCollectionSecondPass(Element node,
		IdentifierCollection collection, java.util.Map persistentClasses, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {

	bindCollectionSecondPass( node, collection, persistentClasses, mappings, inheritedMetas );

	Element subnode = node.element( "collection-id" );
	SimpleValue id = new SimpleValue( collection.getCollectionTable() );
	bindSimpleValue(
			subnode,
			id,
			false,
			IdentifierCollection.DEFAULT_IDENTIFIER_COLUMN_NAME,
			mappings
		);
	collection.setIdentifier( id );
	makeIdentifier( subnode, id, mappings );

}
 
Example #7
Source File: TableBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static void linkJoinColumnWithValueOverridingNameIfImplicit(
		PersistentClass referencedEntity,
		Iterator columnIterator,
		Ejb3JoinColumn[] columns,
		SimpleValue value) {
	for (Ejb3JoinColumn joinCol : columns) {
		Column synthCol = (Column) columnIterator.next();
		if ( joinCol.isNameDeferred() ) {
			//this has to be the default value
			joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value );
		}
		else {
			joinCol.linkWithValue( value );
			joinCol.overrideFromReferencedColumnIfNecessary( synthCol );
		}
	}
}
 
Example #8
Source File: Ejb3JoinColumn.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void linkValueUsingDefaultColumnNaming(
		Column referencedColumn,
		PersistentClass referencedEntity,
		SimpleValue value) {
	String logicalReferencedColumn = getBuildingContext().getMetadataCollector().getLogicalColumnName(
			referencedEntity.getTable(),
			referencedColumn.getQuotedName()
	);
	String columnName = buildDefaultColumnName( referencedEntity, logicalReferencedColumn );

	//yuk side effect on an implicit column
	setLogicalColumnName( columnName );
	setReferencedColumn( logicalReferencedColumn );
	initMappingColumn(
			columnName,
			null, referencedColumn.getLength(),
			referencedColumn.getPrecision(),
			referencedColumn.getScale(),
			getMappingColumn() != null ? getMappingColumn().isNullable() : false,
			referencedColumn.getSqlType(),
			getMappingColumn() != null ? getMappingColumn().isUnique() : false,
			false
	);
	linkWithValue( value );
}
 
Example #9
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 );
}
 
Example #10
Source File: PropertyBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private Property makePropertyAndValue() {
	validateBind();

	LOG.debugf( "MetadataSourceProcessor property %s with lazy=%s", name, lazy );
	final String containerClassName = holder.getClassName();
	holder.startingProperty( property );

	simpleValueBinder = new SimpleValueBinder();
	simpleValueBinder.setBuildingContext( buildingContext );
	simpleValueBinder.setPropertyName( name );
	simpleValueBinder.setReturnedClassName( returnedClassName );
	simpleValueBinder.setColumns( columns );
	simpleValueBinder.setPersistentClassName( containerClassName );
	simpleValueBinder.setType(
			property,
			returnedClass,
			containerClassName,
			holder.resolveAttributeConverterDescriptor( property )
	);
	simpleValueBinder.setReferencedEntityName( referencedEntityName );
	simpleValueBinder.setAccessType( accessType );
	SimpleValue propertyValue = simpleValueBinder.make();
	setValue( propertyValue );
	return makeProperty();
}
 
Example #11
Source File: AnnotationBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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() );
		}
	}
}
 
Example #12
Source File: RelationalObjectBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void bindColumns(
		MappingDocument sourceDocument,
		List<ColumnSource> columnSources,
		SimpleValue simpleValue,
		boolean areColumnsNullableByDefault,
		ColumnNamingDelegate columnNamingDelegate) {
	for ( ColumnSource columnSource : columnSources ) {
		bindColumn(
				sourceDocument,
				columnSource,
				simpleValue,
				areColumnsNullableByDefault,
				columnNamingDelegate
		);
	}
}
 
Example #13
Source File: ModelBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected void bindCollectionIdentifier() {
	final CollectionIdSource idSource = getPluralAttributeSource().getCollectionIdSource();
	if ( idSource != null ) {
		final IdentifierCollection idBagBinding = (IdentifierCollection) getCollectionBinding();
		final SimpleValue idBinding = new SimpleValue(
				mappingDocument,
				idBagBinding.getCollectionTable()
		);

		bindSimpleValueType(
				mappingDocument,
				idSource.getTypeInformation(),
				idBinding
		);

		relationalObjectBinder.bindColumn(
				mappingDocument,
				idSource.getColumnSource(),
				idBinding,
				false,
				new RelationalObjectBinder.ColumnNamingDelegate() {
					@Override
					public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
						return database.toIdentifier( IdentifierCollection.DEFAULT_IDENTIFIER_COLUMN_NAME );
					}
				}
		);

		idBagBinding.setIdentifier( idBinding );

		makeIdentifier(
				mappingDocument,
				new IdentifierGeneratorDefinition( idSource.getGeneratorName(), idSource.getParameters() ),
				null,
				idBinding
		);
	}
}
 
Example #14
Source File: InFlightMetadataCollectorImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void process(InFlightMetadataCollector metadataCollector) {
	final PersistentClass clazz = metadataCollector.getEntityBinding( referencedClass );
	if ( clazz == null ) {
		throw new MappingException( "property-ref to unmapped class: " + referencedClass );
	}

	final Property prop = clazz.getReferencedProperty( propertyName );
	if ( unique ) {
		( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true );
	}
}
 
Example #15
Source File: RelationalObjectBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void bindColumnOrFormula(
		MappingDocument sourceDocument,
		RelationalValueSource relationalValueSource,
		SimpleValue simpleValue,
		boolean areColumnsNullableByDefault,
		ColumnNamingDelegate columnNamingDelegate) {
	bindColumnsAndFormulas(
			sourceDocument,
			Collections.singletonList( relationalValueSource ),
			simpleValue,
			areColumnsNullableByDefault,
			columnNamingDelegate
	);
}
 
Example #16
Source File: SimpleValueBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SimpleValue make() {

		validate();
		LOG.debugf( "building SimpleValue for %s", propertyName );
		if ( table == null ) {
			table = columns[0].getTable();
		}
		simpleValue = new SimpleValue( buildingContext, table );
		if ( isVersion ) {
			simpleValue.makeVersion();
		}
		if ( isNationalized ) {
			simpleValue.makeNationalized();
		}
		if ( isLob ) {
			simpleValue.makeLob();
		}

		linkWithValue();

		boolean isInSecondPass = buildingContext.getMetadataCollector().isInSecondPass();
		if ( !isInSecondPass ) {
			//Defer this to the second pass
			buildingContext.getMetadataCollector().addSecondPass( new SetSimpleValueTypeSecondPass( this ) );
		}
		else {
			//We are already in second pass
			fillSimpleValue();
		}
		return simpleValue;
	}
 
Example #17
Source File: ModelBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void process(InFlightMetadataCollector metadataCollector) {
	log.tracef(
			"Performing delayed property-ref handling [%s, %s, %s]",
			referencedEntityName,
			referencedPropertyName,
			sourceElementSynopsis
	);

	PersistentClass entityBinding = metadataCollector.getEntityBinding( referencedEntityName );
	if ( entityBinding == null ) {
		throw new MappingException(
				String.format(
						Locale.ENGLISH,
						"property-ref [%s] referenced an unmapped entity [%s]",
						sourceElementSynopsis,
						referencedEntityName
				),
				propertyRefOrigin
		);
	}

	Property propertyBinding = entityBinding.getReferencedProperty( referencedPropertyName );
	if ( propertyBinding == null ) {
		throw new MappingException(
				String.format(
						Locale.ENGLISH,
						"property-ref [%s] referenced an unknown entity property [%s#%s]",
						sourceElementSynopsis,
						referencedEntityName,
						referencedPropertyName
				),
				propertyRefOrigin
		);
	}

	if ( isUnique ) {
		( (SimpleValue) propertyBinding.getValue() ).setAlternateUniqueKey( true );
	}
}
 
Example #18
Source File: HibernatePropertyParser.java    From mPaaS with Apache License 2.0 5 votes vote down vote up
/**
 * 构造SimpleValue
 */
private SimpleValue buildSimpleValue(Table table, String type,
									 String columnName, int len) {
	SimpleValue value = new SimpleValue(metadataCollector, table);
	String typeName = null;
	for (Entry<String, String> entry : HBMTYPES.entrySet()) {
		if (entry.getValue().equals(type)) {
			typeName = entry.getKey();
			break;
		}
	}
	value.setTypeName(typeName == null ? type.toLowerCase() : typeName);
	buildColumn(columnName, len, value, table);
	return value;
}
 
Example #19
Source File: IgniteCacheInitializer.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String fieldType(Column currentColumn) {
	Value value = currentColumn.getValue();
	Type type = value.getType();
	while ( type.isEntityType() || type.isComponentType() ) {
		if ( type.isEntityType() ) {
			type = ( (SimpleValue) value ).getMetadata().getIdentifierType( type.getName() );
		}
		if ( type.isComponentType() ) {
			int i = 0;
			boolean columnFound = false;
			// search which nested property is mapped to the given column
			for ( Iterator<Selectable> ci = value.getColumnIterator(); ci.hasNext(); ++i ) {
				if ( currentColumn.getName().equals( ci.next().getText() ) ) {
					type = ( (ComponentType) type ).getSubtypes()[i];
					columnFound = true;
					break;
				}
			}
			if ( !columnFound ) {
				throw new IllegalArgumentException( "Cannot determine type for column " + currentColumn );
			}
		}
	}
	GridType gridType = serviceRegistry.getService( TypeTranslator.class ).getType( type );
	if ( gridType instanceof EnumType ) {
		return enumFieldType( (EnumType) gridType );
	}
	if ( gridType instanceof YesNoType ) {
		return STRING_CLASS_NAME;
	}
	if ( gridType instanceof NumericBooleanType ) {
		return INTEGER_CLASS_NAME;
	}
	Class<?> returnedClass = type.getReturnedClass();
	if ( Character.class.equals( returnedClass ) ) {
		return STRING_CLASS_NAME;
	}
	return returnedClass.getName();
}
 
Example #20
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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() ) {
		// this is either a <version/> tag with no type attribute,
		// or a <timestamp/> tag
		if ( "version".equals( name ) ) {
			val.setTypeName( "integer" );
		}
		else {
			if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
				val.setTypeName( "dbtimestamp" );
			}
			else {
				val.setTypeName( "timestamp" );
			}
		}
	}
	Property prop = new Property();
	prop.setValue( val );
	bindProperty( subnode, prop, mappings, inheritedMetas );
	// for version properties marked as being generated, make sure they are "always"
	// generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
	// but just to make sure...
	if ( prop.getGeneration() == PropertyGeneration.INSERT ) {
		throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
	}
	makeVersion( subnode, val );
	entity.setVersion( prop );
	entity.addProperty( prop );
}
 
Example #21
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void bindSimpleValue(Element node, SimpleValue simpleValue, boolean isNullable,
		String path, Mappings mappings) throws MappingException {
	bindSimpleValueType( node, simpleValue, mappings );

	bindColumnsOrFormula( node, simpleValue, path, isNullable, mappings );

	Attribute fkNode = node.attribute( "foreign-key" );
	if ( fkNode != null ) simpleValue.setForeignKeyName( fkNode.getValue() );
}
 
Example #22
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 );
}
 
Example #23
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void bindColumnsOrFormula(Element node, SimpleValue simpleValue, String path,
		boolean isNullable, Mappings mappings) {
	Attribute formulaNode = node.attribute( "formula" );
	if ( formulaNode != null ) {
		Formula f = new Formula();
		f.setFormula( formulaNode.getText() );
		simpleValue.addFormula( f );
	}
	else {
		bindColumns( node, simpleValue, isNullable, true, path, mappings );
	}
}
 
Example #24
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static final void makeVersion(Element node, SimpleValue model) {

		// VERSION UNSAVED-VALUE
		Attribute nullValueNode = node.attribute( "unsaved-value" );
		if ( nullValueNode != null ) {
			model.setNullValue( nullValueNode.getValue() );
		}
		else {
			model.setNullValue( "undefined" );
		}

	}
 
Example #25
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Called for Lists, arrays, primitive arrays
 */
public static void bindListSecondPass(Element node, List list, java.util.Map classes,
		Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

	bindCollectionSecondPass( node, list, classes, mappings, inheritedMetas );

	Element subnode = node.element( "list-index" );
	if ( subnode == null ) subnode = node.element( "index" );
	SimpleValue iv = new SimpleValue( list.getCollectionTable() );
	bindSimpleValue(
			subnode,
			iv,
			list.isOneToMany(),
			IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
			mappings
		);
	iv.setTypeName( "integer" );
	list.setIndex( iv );
	String baseIndex = subnode.attributeValue( "base" );
	if ( baseIndex != null ) list.setBaseIndex( Integer.parseInt( baseIndex ) );
	list.setIndexNodeName( subnode.attributeValue("node") );

	if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
		String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
		PersistentClass referenced = mappings.getClass( entityName );
		IndexBackref ib = new IndexBackref();
		ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" );
		ib.setUpdateable( false );
		ib.setSelectable( false );
		ib.setCollectionRole( list.getRole() );
		ib.setEntityName( list.getOwner().getEntityName() );
		ib.setValue( list.getIndex() );
		// ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
		// ).setNullable(false);
		referenced.addProperty( ib );
	}
}
 
Example #26
Source File: ExecutionEnvironment.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void applyCacheSettings(Configuration configuration) {
	if ( settings.getCacheConcurrencyStrategy() != null ) {
		Iterator iter = configuration.getClassMappings();
		while ( iter.hasNext() ) {
			PersistentClass clazz = (PersistentClass) iter.next();
			Iterator props = clazz.getPropertyClosureIterator();
			boolean hasLob = false;
			while ( props.hasNext() ) {
				Property prop = (Property) props.next();
				if ( prop.getValue().isSimpleValue() ) {
					String type = ( ( SimpleValue ) prop.getValue() ).getTypeName();
					if ( "blob".equals(type) || "clob".equals(type) ) {
						hasLob = true;
					}
					if ( Blob.class.getName().equals(type) || Clob.class.getName().equals(type) ) {
						hasLob = true;
					}
				}
			}
			if ( !hasLob && !clazz.isInherited() && settings.overrideCacheStrategy() ) {
				configuration.setCacheConcurrencyStrategy( clazz.getEntityName(), settings.getCacheConcurrencyStrategy() );
			}
		}
		iter = configuration.getCollectionMappings();
		while ( iter.hasNext() ) {
			Collection coll = (Collection) iter.next();
			configuration.setCollectionCacheConcurrencyStrategy( coll.getRole(), settings.getCacheConcurrencyStrategy() );
		}
	}
}
 
Example #27
Source File: Dom4jAccessorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Property generateIdProperty() {
	SimpleValue value = new SimpleValue();
	value.setTypeName( "long" );

	Property property = new Property();
	property.setName( "id" );
	property.setNodeName( "@id" );
	property.setValue( value );

	return property;
}
 
Example #28
Source File: Dom4jAccessorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Property generateTextProperty() {
	SimpleValue value = new SimpleValue();
	value.setTypeName( "string" );

	Property property = new Property();
	property.setName( "text" );
	property.setNodeName( "." );
	property.setValue( value );

	return property;
}
 
Example #29
Source File: Dom4jAccessorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Property generateAccountIdProperty() {
	SimpleValue value = new SimpleValue();
	value.setTypeName( "long" );

	Property property = new Property();
	property.setName( "number" );
	property.setNodeName( "account/@num" );
	property.setValue( value );

	return property;
}
 
Example #30
Source File: Dom4jAccessorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Property generateNameProperty() {
	SimpleValue value = new SimpleValue();
	value.setTypeName( "string" );

	Property property = new Property();
	property.setName( "name" );
	property.setNodeName( "name" );
	property.setValue( value );

	return property;
}