org.hibernate.mapping.List Java Examples

The following examples show how to use org.hibernate.mapping.List. 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 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 #2
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 #3
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
		throws MappingException {
	HbmBinder.bindListSecondPass(
			node,
			(List) collection,
			persistentClasses,
			mappings,
			inheritedMetas 
		);
}
 
Example #4
Source File: ListBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Collection createCollection(PersistentClass persistentClass) {
	return new org.hibernate.mapping.List( getBuildingContext(), persistentClass );
}
 
Example #5
Source File: ListBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void bindIndex(final MetadataBuildingContext buildingContext) {
	if ( !indexColumn.isImplicit() ) {
		PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder(
				this.collection,
				StringHelper.qualify( this.collection.getRole(), "key" ),
				null,
				null,
				propertyHolder,
				getBuildingContext()
		);
		List list = (List) this.collection;
		if ( !list.isOneToMany() ) indexColumn.forceNotNull();
		indexColumn.setPropertyHolder( valueHolder );
		SimpleValueBinder value = new SimpleValueBinder();
		value.setColumns( new Ejb3Column[] { indexColumn } );
		value.setExplicitType( "integer" );
		value.setBuildingContext( getBuildingContext() );
		SimpleValue indexValue = value.make();
		indexColumn.linkWithValue( indexValue );
		list.setIndex( indexValue );
		list.setBaseIndex( indexColumn.getBase() );
		if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
			String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
			PersistentClass referenced = buildingContext.getMetadataCollector().getEntityBinding( entityName );
			IndexBackref ib = new IndexBackref();
			ib.setName( '_' + propertyName + "IndexBackref" );
			ib.setUpdateable( false );
			ib.setSelectable( false );
			ib.setCollectionRole( list.getRole() );
			ib.setEntityName( list.getOwner().getEntityName() );
			ib.setValue( list.getIndex() );
			referenced.addProperty( ib );
		}
	}
	else {
		Collection coll = this.collection;
		throw new AnnotationException(
				"List/array has to be annotated with an @OrderColumn (or @IndexColumn): "
						+ coll.getRole()
		);
	}
}
 
Example #6
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
ListSecondPass(Element node, Mappings mappings, List collection, java.util.Map inheritedMetas) {
	super( node, mappings, collection, inheritedMetas );
}
 
Example #7
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Collection create(Element node, String path, PersistentClass owner,
		Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
	List list = new List( owner );
	bindCollection( node, list, owner.getEntityName(), path, mappings, inheritedMetas );
	return list;
}
 
Example #8
Source File: ValueVisitorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
public Object accept(List list) {
	return validate(List.class, list);

}