Java Code Examples for org.hibernate.mapping.RootClass#getEntityName()

The following examples show how to use org.hibernate.mapping.RootClass#getEntityName() . 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: NaturalIdDataCachingConfigImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public NaturalIdDataCachingConfigImpl(
		RootClass rootEntityDescriptor,
		AccessType accessType) {
	super( accessType );
	this.rootEntityDescriptor = rootEntityDescriptor;
	this.navigableRole = new NavigableRole( rootEntityDescriptor.getEntityName() );

	// sucks that we need to do this here.  persister does the same "calculation"
	this.mutable = hasAnyMutableNaturalIdProps();
}
 
Example 2
Source File: ModelBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void bindSimpleEntityIdentifier(
		MappingDocument sourceDocument,
		final EntityHierarchySourceImpl hierarchySource,
		RootClass rootEntityDescriptor) {
	final IdentifierSourceSimple idSource = (IdentifierSourceSimple) hierarchySource.getIdentifierSource();

	final SimpleValue idValue = new SimpleValue(
			sourceDocument,
			rootEntityDescriptor.getTable()
	);
	rootEntityDescriptor.setIdentifier( idValue );

	bindSimpleValueType(
			sourceDocument,
			idSource.getIdentifierAttributeSource().getTypeInformation(),
			idValue
	);

	final String propertyName = idSource.getIdentifierAttributeSource().getName();
	if ( propertyName == null || !rootEntityDescriptor.hasPojoRepresentation() ) {
		if ( !idValue.isTypeSpecified() ) {
			throw new MappingException(
					"must specify an identifier type: " + rootEntityDescriptor.getEntityName(),
					sourceDocument.getOrigin()
			);
		}
	}
	else {
		idValue.setTypeUsingReflection( rootEntityDescriptor.getClassName(), propertyName );
	}

	relationalObjectBinder.bindColumnsAndFormulas(
			sourceDocument,
			( (RelationalValueSourceContainer) idSource.getIdentifierAttributeSource() ).getRelationalValueSources(),
			idValue,
			false,
			new RelationalObjectBinder.ColumnNamingDelegate() {
				@Override
				public Identifier determineImplicitName(final LocalMetadataBuildingContext context) {
					context.getBuildingOptions().getImplicitNamingStrategy().determineIdentifierColumnName(
							new ImplicitIdentifierColumnNameSource() {
								@Override
								public EntityNaming getEntityNaming() {
									return hierarchySource.getRoot().getEntityNamingSource();
								}

								@Override
								public AttributePath getIdentifierAttributePath() {
									return idSource.getIdentifierAttributeSource().getAttributePath();
								}

								@Override
								public MetadataBuildingContext getBuildingContext() {
									return context;
								}
							}
					);
					return database.toIdentifier( propertyName );
				}
			}
	);

	if ( propertyName != null ) {
		Property prop = new Property();
		prop.setValue( idValue );
		bindProperty(
				sourceDocument,
				idSource.getIdentifierAttributeSource(),
				prop
		);
		rootEntityDescriptor.setIdentifierProperty( prop );
		rootEntityDescriptor.setDeclaredIdentifierProperty( prop );
	}

	makeIdentifier(
			sourceDocument,
			idSource.getIdentifierGeneratorDescriptor(),
			idSource.getUnsavedValue(),
			idValue
	);
}
 
Example 3
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static void bindSimpleId(Element idNode, RootClass entity, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {
	String propertyName = idNode.attributeValue( "name" );

	SimpleValue id = new SimpleValue( entity.getTable() );
	entity.setIdentifier( id );

	// if ( propertyName == null || entity.getPojoRepresentation() == null ) {
	// bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
	// if ( !id.isTypeSpecified() ) {
	// throw new MappingException( "must specify an identifier type: " + entity.getEntityName()
	// );
	// }
	// }
	// else {
	// bindSimpleValue( idNode, id, false, propertyName, mappings );
	// PojoRepresentation pojo = entity.getPojoRepresentation();
	// id.setTypeUsingReflection( pojo.getClassName(), propertyName );
	//
	// Property prop = new Property();
	// prop.setValue( id );
	// bindProperty( idNode, prop, mappings, inheritedMetas );
	// entity.setIdentifierProperty( prop );
	// }

	if ( propertyName == null ) {
		bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
	}
	else {
		bindSimpleValue( idNode, id, false, propertyName, mappings );
	}

	if ( propertyName == null || !entity.hasPojoRepresentation() ) {
		if ( !id.isTypeSpecified() ) {
			throw new MappingException( "must specify an identifier type: "
				+ entity.getEntityName() );
		}
	}
	else {
		id.setTypeUsingReflection( entity.getClassName(), propertyName );
	}

	if ( propertyName != null ) {
		Property prop = new Property();
		prop.setValue( id );
		bindProperty( idNode, prop, mappings, inheritedMetas );
		entity.setIdentifierProperty( prop );
	}

	// TODO:
	/*
	 * if ( id.getHibernateType().getReturnedClass().isArray() ) throw new MappingException(
	 * "illegal use of an array as an identifier (arrays don't reimplement equals)" );
	 */
	makeIdentifier( idNode, id, mappings );
}