SessionImplementor getEntityPersister - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SessionImplementor getEntityPersister method.

This code example shows how to use the following methods:getEntityPersister
	private String entityName;
 
	public Serializable generate(SessionImplementor session, Object obj) throws HibernateException {
		//TODO: cache the persister, this shows up in yourkit 
		final Serializable id = session.getEntityPersister( entityName, obj ).getIdentifier( obj, session );
		if ( id == null ) {
			throw new IdentifierGenerationException(
					"ids for this class must be manually assigned before calling save(): " + entityName
			); 
		} 
		 
		return id;
	} 
 
	public void configure(Type type, Properties params, Dialect d) throws MappingException {
		entityName = params.getProperty(ENTITY_NAME);
		if ( entityName == null ) {
			throw new MappingException("no entity name");
		} 
	} 
8
CodeRank
This code example shows how to use the following methods:getContextEntityIdentifier, getEntityPersister, getFactory, getInterceptor, getPersistenceContext
 
	/** 
	 * {@inheritDoc} 
	 */ 
	public Serializable generate(SessionImplementor sessionImplementor, Object object) {
		Session session = ( Session ) sessionImplementor;
 
		final EntityPersister persister = sessionImplementor.getFactory().getEntityPersister( entityName );
		Object associatedObject = persister.getPropertyValue( object, propertyName );
		if ( associatedObject == null ) { 
			throw new IdentifierGenerationException(
					"attempted to assign id from null one-to-one property [" + getRole() + "]"
			); 
		} 
 
		final EntityType foreignValueSourceType;
		final Type propertyType = persister.getPropertyType( propertyName );
		if ( propertyType.isEntityType() ) {
			// the normal case 
			foreignValueSourceType = (EntityType) propertyType;

7
CodeRank
This code example shows how to use the following methods:getEntityPersister, getFactory, getInterceptor, getPersistenceContext
			// if it was a reference to self, don't need to nullify 
			// unless we are using native id generation, in which 
			// case we definitely need to nullify 
			if ( object == self ) { 
				return isEarlyInsert || (
					isDelete &&
					session.getFactory()
						.getDialect()
						.hasSelfReferentialForeignKeyBug()
				); 
			} 
	 
			// See if the entity is already bound to this session, if not look at the 
			// entity identifier and assume that the entity is persistent if the 
			// id is not "unsaved" (that is, we rely on foreign keys to keep 
			// database integrity) 
	 
			EntityEntry entityEntry = session.getPersistenceContext().getEntry(object);
			if ( entityEntry==null ) {
				return isTransient(entityName, object, null, session);

6
CodeRank
This code example shows how to use the following methods:getContextEntityIdentifier, getEntityPersister, getFactory, getInterceptor, getPersistenceContext
			String[] names, 
			SessionImplementor session, 
			Object owner) throws HibernateException, SQLException { 
		return resolve( hydrate(rs, names, session, owner), session, owner ); 
	} 
 
	/** 
	 * Two entities are considered the same when their instances are the same. 
	 * 
	 * 
	 * @param x One entity instance 
	 * @param y Another entity instance 
	 * @return True if x == y; false otherwise. 
	 */ 
	public final boolean isSame(Object x, Object y) { 
		return x == y; 
	} 
 
	/** 
	 * {@inheritDoc} 

6
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush

7
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush

7
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush

7
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush
	} 
 
	@Override 
	protected CascadingAction getCascadeAction() { 
		return EJB3CascadingAction.PERSIST_SKIPLAZY; 
	} 
} 

7
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getInterceptor, getPersistenceContext
	 * @throws HibernateException 
	 */ 
	public void onDelete(DeleteEvent event, Set transientEntities) throws HibernateException { 
 
		final EventSource source = event.getSession(); 
 
		final PersistenceContext persistenceContext = source.getPersistenceContext(); 
		Object entity = persistenceContext.unproxyAndReassociate( event.getObject() ); 
 
		EntityEntry entityEntry = persistenceContext.getEntry( entity ); 
		final EntityPersister persister; 
		final Serializable id; 
		final Object version; 
 
		if ( entityEntry == null ) { 
            LOG.trace("Entity was not persistent in delete processing"); 
 
			persister = source.getEntityPersister( event.getEntityName(), entity ); 
 
			if ( ForeignKeys.isTransient( persister.getEntityName(), entity, null, source ) ) { 

6
CodeRank
This code example shows how to use the following methods:getEntityPersister
	public Object nullSafeGet( 
			ResultSet rs, 
			String name, 
			SessionImplementor session, 
			Object owner) throws HibernateException, SQLException { 
		final Object discriminatorValue = underlyingType.nullSafeGet( rs, name, session, owner ); 
		final String entityName = persister.getSubclassForDiscriminatorValue( discriminatorValue ); 
		if ( entityName == null ) { 
			throw new HibernateException( "Unable to resolve discriminator value [" + discriminatorValue + "] to entity name" ); 
		} 
		final EntityPersister entityPersister = session.getEntityPersister( entityName, null ); 
        return ( EntityMode.POJO == entityPersister.getEntityMode() ) ? entityPersister.getMappedClass() : entityName; 
	} 
 
	public void nullSafeSet( 
			PreparedStatement st, 
			Object value, 
			int index, 
			boolean[] settable, 
			SessionImplementor session) throws HibernateException, SQLException { 
5
CodeRank
getEntityPersister Method Overview
Get the EntityPersister for any instance
See Code Examples for other Hibernate ORM SessionImplementor Methods: