Java Code Examples for org.hibernate.engine.spi.SessionImplementor.bestGuessEntityName()

The following are Jave code examples for showing how to use bestGuessEntityName() of the org.hibernate.engine.spi.SessionImplementor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: AnyType.java   View Source Code Vote up 6 votes
@Override
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException {
	if ( value == null ) {
		return null;
	}
	else {
		return new ObjectTypeCacheEntry(
				session.bestGuessEntityName( value ),
				ForeignKeys.getEntityIdentifierIfNotUnsaved(
						session.bestGuessEntityName( value ),
						value,
						session
				)
		);
	}
}
 
Example 2
Project: lams   File: AnyType.java   View Source Code Vote up 5 votes
@Override
public void nullSafeSet(PreparedStatement st, Object value,	int index, boolean[] settable, SessionImplementor session)
		throws HibernateException, SQLException {
	Serializable id;
	String entityName;
	if ( value == null ) {
		id = null;
		entityName = null;
	}
	else {
		entityName = session.bestGuessEntityName( value );
		id = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, value, session );
	}

	// discriminatorType is assumed to be single-column type
	if ( settable == null || settable[0] ) {
		discriminatorType.nullSafeSet( st, entityName, index, session );
	}
	if ( settable == null ) {
		identifierType.nullSafeSet( st, id, index+1, session );
	}
	else {
		final boolean[] idSettable = new boolean[ settable.length-1 ];
		System.arraycopy( settable, 1, idSettable, 0, idSettable.length );
		identifierType.nullSafeSet( st, id, index+1, idSettable, session );
	}
}
 
Example 3
Project: lams   File: AnyType.java   View Source Code Vote up 5 votes
@Override
public Object replace(Object original, Object target, SessionImplementor session, Object owner, Map copyCache)
		throws HibernateException {
	if ( original == null ) {
		return null;
	}
	else {
		final String entityName = session.bestGuessEntityName( original );
		final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, original, session );
		return session.internalLoad( entityName, id, false, false );
	}
}
 
Example 4
Project: lams   File: AnyType.java   View Source Code Vote up 5 votes
@Override
public Object[] getPropertyValues(Object component, SessionImplementor session) throws HibernateException {
	return new Object[] {
			session.bestGuessEntityName( component ),
			getIdentifier( component, session )
	};
}
 
Example 5
Project: lams   File: AnyType.java   View Source Code Vote up 4 votes
@Override
public Object getPropertyValue(Object component, int i, SessionImplementor session) throws HibernateException {
	return i==0
			? session.bestGuessEntityName( component )
			: getIdentifier( component, session );
}