org.hibernate.persister.entity.JoinedSubclassEntityPersister Java Examples

The following examples show how to use org.hibernate.persister.entity.JoinedSubclassEntityPersister. 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: PersisterFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static EntityPersister createClassPersister(
		PersistentClass model, 
		CacheConcurrencyStrategy cache, 
		SessionFactoryImplementor factory,
		Mapping cfg)
throws HibernateException {
	Class persisterClass = model.getEntityPersisterClass();
	if (persisterClass==null || persisterClass==SingleTableEntityPersister.class) {
		return new SingleTableEntityPersister(model, cache, factory, cfg);
	}
	else if (persisterClass==JoinedSubclassEntityPersister.class) {
		return new JoinedSubclassEntityPersister(model, cache, factory, cfg);
	}
	else if (persisterClass==UnionSubclassEntityPersister.class) {
		return new UnionSubclassEntityPersister(model, cache, factory, cfg);
	}
	else {
		return create(persisterClass, model, cache, factory, cfg);
	}
}
 
Example #2
Source File: StandardPersisterClassResolver.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Class<? extends EntityPersister> joinedSubclassEntityPersister() {
	return JoinedSubclassEntityPersister.class;
}
 
Example #3
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void bindJoinedSubclass(Element node, JoinedSubclass joinedSubclass,
		Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

	bindClass( node, joinedSubclass, mappings, inheritedMetas );
	inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from
																// <joined-subclass>

	// joined subclasses
	if ( joinedSubclass.getEntityPersisterClass() == null ) {
		joinedSubclass.getRootClass()
			.setEntityPersisterClass( JoinedSubclassEntityPersister.class );
	}

	Attribute schemaNode = node.attribute( "schema" );
	String schema = schemaNode == null ?
			mappings.getSchemaName() : schemaNode.getValue();

	Attribute catalogNode = node.attribute( "catalog" );
	String catalog = catalogNode == null ?
			mappings.getCatalogName() : catalogNode.getValue();

	Table mytable = mappings.addTable(
			schema,
			catalog,
			getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ),
			getSubselect( node ),
			false
		);
	joinedSubclass.setTable( mytable );
	bindComment(mytable, node);

	log.info(
			"Mapping joined-subclass: " + joinedSubclass.getEntityName() +
			" -> " + joinedSubclass.getTable().getName()
		);

	// KEY
	Element keyNode = node.element( "key" );
	SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() );
	joinedSubclass.setKey( key );
	key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
	bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings );

	// model.getKey().setType( new Type( model.getIdentifier() ) );
	joinedSubclass.createPrimaryKey();
	joinedSubclass.createForeignKey();

	// CHECK
	Attribute chNode = node.attribute( "check" );
	if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() );

	// properties
	createClassProperties( node, joinedSubclass, mappings, inheritedMetas );

}