Java Code Examples for org.hibernate.EntityMode#POJO
The following examples show how to use
org.hibernate.EntityMode#POJO .
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: Property.java From lams with GNU General Public License v2.0 | 6 votes |
public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException { String accessName = getPropertyAccessorName(); if ( accessName == null ) { if ( clazz == null || java.util.Map.class.equals( clazz ) ) { accessName = "map"; } else { accessName = "property"; } } final EntityMode entityMode = clazz == null || java.util.Map.class.equals( clazz ) ? EntityMode.MAP : EntityMode.POJO; return resolveServiceRegistry().getService( PropertyAccessStrategyResolver.class ).resolvePropertyAccessStrategy( clazz, accessName, entityMode ); }
Example 2
Source File: DiscriminatorType.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Object nullSafeGet( ResultSet rs, String name, SharedSessionContractImplementor 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; }
Example 3
Source File: CustomPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public EntityMode guessEntityMode(Object object) { if ( !isInstance(object, EntityMode.POJO) ) { return null; } else { return EntityMode.POJO; } }
Example 4
Source File: SessionFactoryImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void evictCollection(String roleName, Serializable id) throws HibernateException { CollectionPersister p = getCollectionPersister(roleName); if ( p.hasCache() ) { if ( log.isDebugEnabled() ) { log.debug( "evicting second-level cache: " + MessageHelper.collectionInfoString(p, id, this) ); } CacheKey cacheKey = new CacheKey( id, p.getKeyType(), p.getRole(), EntityMode.POJO, this ); p.getCache().remove( cacheKey ); } }
Example 5
Source File: SessionFactoryImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void evict(Class persistentClass, Serializable id) throws HibernateException { EntityPersister p = getEntityPersister( persistentClass.getName() ); if ( p.hasCache() ) { if ( log.isDebugEnabled() ) { log.debug( "evicting second-level cache: " + MessageHelper.infoString(p, id, this) ); } CacheKey cacheKey = new CacheKey( id, p.getIdentifierType(), p.getRootEntityName(), EntityMode.POJO, this ); p.getCache().remove( cacheKey ); } }
Example 6
Source File: SessionFactoryImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void evictEntity(String entityName, Serializable id) throws HibernateException { EntityPersister p = getEntityPersister(entityName); if ( p.hasCache() ) { if ( log.isDebugEnabled() ) { log.debug( "evicting second-level cache: " + MessageHelper.infoString(p, id, this) ); } CacheKey cacheKey = new CacheKey( id, p.getIdentifierType(), p.getRootEntityName(), EntityMode.POJO, this ); p.getCache().remove( cacheKey ); } }
Example 7
Source File: CriteriaQueryTranslator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Get the a typed value for the given property value. */ public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value) throws HibernateException { // Detect discriminator values... if ( value instanceof Class ) { Class entityClass = ( Class ) value; Queryable q = SessionFactoryHelper.findQueryableUsingImports( sessionFactory, entityClass.getName() ); if ( q != null ) { Type type = q.getDiscriminatorType(); String stringValue = q.getDiscriminatorSQLValue(); // Convert the string value into the proper type. if ( type instanceof NullableType ) { NullableType nullableType = ( NullableType ) type; value = nullableType.fromStringValue( stringValue ); } else { throw new QueryException( "Unsupported discriminator type " + type ); } return new TypedValue( type, value, EntityMode.POJO ); } } // Otherwise, this is an ordinary value. return new TypedValue( getTypeUsingProjection( subcriteria, propertyName ), value, EntityMode.POJO ); }
Example 8
Source File: CriteriaQueryTranslator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public TypedValue getTypedIdentifierValue(Criteria subcriteria, Object value) { final Loadable loadable = ( Loadable ) getPropertyMapping( getEntityName( subcriteria ) ); return new TypedValue( loadable.getIdentifierType(), value, EntityMode.POJO ); }
Example 9
Source File: SQLCriterion.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
protected SQLCriterion(String sql, Object[] values, Type[] types) { this.sql = sql; typedValues = new TypedValue[values.length]; for ( int i=0; i<typedValues.length; i++ ) { typedValues[i] = new TypedValue( types[i], values[i], EntityMode.POJO ); } }
Example 10
Source File: SubqueryExpression.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { Type[] types = params.getPositionalParameterTypes(); Object[] values = params.getPositionalParameterValues(); TypedValue[] tv = new TypedValue[types.length]; for ( int i=0; i<types.length; i++ ) { tv[i] = new TypedValue( types[i], values[i], EntityMode.POJO ); } return tv; }
Example 11
Source File: SimpleSubqueryExpression.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { TypedValue[] superTv = super.getTypedValues(criteria, criteriaQuery); TypedValue[] result = new TypedValue[superTv.length+1]; System.arraycopy(superTv, 0, result, 1, superTv.length); result[0] = new TypedValue( getTypes()[0], value, EntityMode.POJO ); return result; }
Example 12
Source File: ComponentMetamodel.java From lams with GNU General Public License v2.0 | 5 votes |
private ComponentMetamodel(Component component, ComponentTuplizerFactory componentTuplizerFactory){ this.role = component.getRoleName(); this.isKey = component.isKey(); propertySpan = component.getPropertySpan(); properties = new StandardProperty[propertySpan]; Iterator itr = component.getPropertyIterator(); int i = 0; while ( itr.hasNext() ) { Property property = ( Property ) itr.next(); properties[i] = PropertyFactory.buildStandardProperty( property, false ); propertyIndexes.put( property.getName(), i ); i++; } entityMode = component.hasPojoRepresentation() ? EntityMode.POJO : EntityMode.MAP; // todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel final String tuplizerClassName = component.getTuplizerImplClassName( entityMode ); this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer( entityMode, component ) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component ); final ConfigurationService cs = component.getMetadata().getMetadataBuildingOptions().getServiceRegistry() .getService(ConfigurationService.class); this.createEmptyCompositesEnabled = ConfigurationHelper.getBoolean( Environment.CREATE_EMPTY_COMPOSITES_ENABLED, cs.getSettings(), false ); }
Example 13
Source File: SizeExpression.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { return new TypedValue[] { new TypedValue( Hibernate.INTEGER, new Integer(size), EntityMode.POJO ) }; }
Example 14
Source File: PojoEntityTuplizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public EntityMode getEntityMode() { return EntityMode.POJO; }
Example 15
Source File: AbstractEntitySourceImpl.java From lams with GNU General Public License v2.0 | 4 votes |
protected EntityMode determineEntityMode() { return StringHelper.isNotEmpty( entityNamingSource.getClassName() ) ? EntityMode.POJO : EntityMode.MAP; }
Example 16
Source File: StatelessSessionImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public EntityMode getEntityMode() { return EntityMode.POJO; }
Example 17
Source File: StatelessSessionImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public EntityMode getEntityMode() { return EntityMode.POJO; }
Example 18
Source File: CustomPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
private void checkEntityMode(EntityMode entityMode) { if ( EntityMode.POJO != entityMode ) { throw new IllegalArgumentException( "Unhandled EntityMode : " + entityMode ); } }
Example 19
Source File: PojoEntityTuplizer.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public EntityMode getEntityMode() { return EntityMode.POJO; }
Example 20
Source File: ProxyInterceptor.java From cacheonix-core with GNU Lesser General Public License v2.1 | 3 votes |
/** * The callback from Hibernate in order to build an instance of the * entity represented by the given entity name. Here, we build a * {@link Proxy} representing the entity. * * @param entityName The entity name for which to create an instance. In our setup, * this is the interface name. * @param entityMode The entity mode in which to create an instance. Here, we are only * interestes in custom behavior for the POJO entity mode. * @param id The identifier value for the given entity. * @return The instantiated instance. */ public Object instantiate(String entityName, EntityMode entityMode, Serializable id) { if ( entityMode == EntityMode.POJO ) { if ( Customer.class.getName().equals( entityName ) ) { return ProxyHelper.newCustomerProxy( id ); } else if ( Company.class.getName().equals( entityName ) ) { return ProxyHelper.newCompanyProxy( id ); } } return super.instantiate( entityName, entityMode, id ); }