本文整理汇总了Java中org.hibernate.EntityMode类的典型用法代码示例。如果您正苦于以下问题:Java EntityMode类的具体用法?Java EntityMode怎么用?Java EntityMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityMode类属于org.hibernate包,在下文中一共展示了EntityMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindPojoRepresentation
import org.hibernate.EntityMode; //导入依赖的package包/类
private static void bindPojoRepresentation(Element node, PersistentClass entity,
Mappings mappings, java.util.Map metaTags) {
String className = getClassName( node.attribute( "name" ), mappings );
String proxyName = getClassName( node.attribute( "proxy" ), mappings );
entity.setClassName( className );
if ( proxyName != null ) {
entity.setProxyInterfaceName( proxyName );
entity.setLazy( true );
}
else if ( entity.isLazy() ) {
entity.setProxyInterfaceName( className );
}
Element tuplizer = locateTuplizerDefinition( node, EntityMode.POJO );
if ( tuplizer != null ) {
entity.addTuplizer( EntityMode.POJO, tuplizer.attributeValue( "class" ) );
}
}
示例2: ComponentMetamodel
import org.hibernate.EntityMode; //导入依赖的package包/类
public ComponentMetamodel(Component component) {
// this.sessionFactory = sessionFactory;
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 ComponentTuplizerFactory componentTuplizerFactory = new ComponentTuplizerFactory();
final String tuplizerClassName = component.getTuplizerImplClassName( entityMode );
this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer(
entityMode,
component
) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );
}
示例3: EntityEntry
import org.hibernate.EntityMode; //导入依赖的package包/类
/**
* @deprecated the tenantId and entityMode parameters where removed: this constructor accepts but ignores them.
* Use the other constructor!
*/
@Deprecated
public EntityEntry(
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,
final EntityPersister persister,
final EntityMode entityMode,
final String tenantId,
final boolean disableVersionIncrement,
final boolean lazyPropertiesAreUnfetched,
final PersistenceContext persistenceContext) {
this( status, loadedState, rowId, id, version, lockMode, existsInDatabase,
persister,disableVersionIncrement, lazyPropertiesAreUnfetched, persistenceContext );
}
示例4: processComponent
import org.hibernate.EntityMode; //导入依赖的package包/类
@Override
Object processComponent(Object component, CompositeType componentType) throws HibernateException {
if ( component != null ) {
Object[] values = componentType.getPropertyValues( component, getSession() );
Type[] types = componentType.getSubtypes();
boolean substituteComponent = false;
for ( int i = 0; i < types.length; i++ ) {
Object result = processValue( values[i], types[i] );
if ( result != null ) {
values[i] = result;
substituteComponent = true;
}
}
if ( substituteComponent ) {
componentType.setPropertyValues( component, values, EntityMode.POJO );
}
}
return null;
}
示例5: bindClass
import org.hibernate.EntityMode; //导入依赖的package包/类
/**
* Binds the specified persistant class to the runtime model based on the
* properties defined in the domain class
*
* @param domainClass The Grails domain class
* @param persistentClass The persistant class
* @param mappings Existing mappings
*/
protected void bindClass(PersistentEntity domainClass, PersistentClass persistentClass, InFlightMetadataCollector mappings) {
// set lazy loading for now
persistentClass.setLazy(true);
final String entityName = domainClass.getName();
persistentClass.setEntityName(entityName);
persistentClass.setJpaEntityName(unqualify(entityName));
persistentClass.setProxyInterfaceName(entityName);
persistentClass.setClassName(entityName);
persistentClass.addTuplizer(EntityMode.POJO, GroovyAwarePojoEntityTuplizer.class.getName());
// set dynamic insert to false
persistentClass.setDynamicInsert(false);
// set dynamic update to false
persistentClass.setDynamicUpdate(false);
// set select before update to false
persistentClass.setSelectBeforeUpdate(false);
// add import to mappings
String en = persistentClass.getEntityName();
if (mappings.getMetadataBuildingOptions().getMappingDefaults().isAutoImportEnabled() && en.indexOf('.') > 0) {
String unqualified = unqualify(en);
mappings.addImport(unqualified, en);
}
}
示例6: write
import org.hibernate.EntityMode; //导入依赖的package包/类
@Override
public void write(ObjectDataOutput out, CacheKey object)
throws IOException {
try {
Object key = UNSAFE.getObject(object, KEY_OFFSET);
Type type = (Type) UNSAFE.getObject(object, TYPE_OFFSET);
String entityOrRoleName = (String) UNSAFE.getObject(object, ENTITY_OR_ROLE_NAME_OFFSET);
EntityMode entityMode = (EntityMode) UNSAFE.getObject(object, ENTITY_MODE_OFFSET);
int hashCode = UNSAFE.getInt(object, HASH_CODE_OFFSET);
out.writeObject(key);
out.writeObject(type);
out.writeUTF(entityOrRoleName);
out.writeUTF(entityMode.toString());
out.writeInt(hashCode);
} catch (Exception e) {
if (e instanceof IOException) {
throw (IOException) e;
}
throw new IOException(e);
}
}
示例7: read
import org.hibernate.EntityMode; //导入依赖的package包/类
@Override
public CacheKey read(ObjectDataInput in)
throws IOException {
try {
Object key = in.readObject();
Type type = in.readObject();
String entityOrRoleName = in.readUTF();
EntityMode entityMode = EntityMode.parse(in.readUTF());
int hashCode = in.readInt();
CacheKey cacheKey = (CacheKey) UNSAFE.allocateInstance(CacheKey.class);
UNSAFE.putObjectVolatile(cacheKey, KEY_OFFSET, key);
UNSAFE.putObjectVolatile(cacheKey, TYPE_OFFSET, type);
UNSAFE.putObjectVolatile(cacheKey, ENTITY_OR_ROLE_NAME_OFFSET, entityOrRoleName);
UNSAFE.putObjectVolatile(cacheKey, ENTITY_MODE_OFFSET, entityMode);
UNSAFE.putIntVolatile(cacheKey, HASH_CODE_OFFSET, hashCode);
return cacheKey;
} catch (Exception e) {
if (e instanceof IOException) {
throw (IOException) e;
}
throw new IOException(e);
}
}
示例8: createFilterKeys
import org.hibernate.EntityMode; //导入依赖的package包/类
public static Set createFilterKeys(Map enabledFilters, EntityMode entityMode) {
if ( enabledFilters.size()==0 ) return null;
Set result = new HashSet();
Iterator iter = enabledFilters.values().iterator();
while ( iter.hasNext() ) {
FilterImpl filter = (FilterImpl) iter.next();
FilterKey key = new FilterKey(
filter.getName(),
filter.getParameters(),
filter.getFilterDefinition().getParameterTypes(),
entityMode
);
result.add(key);
}
return result;
}
示例9: isCached
import org.hibernate.EntityMode; //导入依赖的package包/类
protected static boolean isCached(
PersistenceContext context,
Serializable collectionKey,
CollectionPersister persister,
EntityMode entityMode) {
if ( persister.hasCache() ) {
CacheKey cacheKey = new CacheKey(
collectionKey,
persister.getKeyType(),
persister.getRole(),
entityMode,
context.getSession().getFactory()
);
return persister.getCacheAccessStrategy().get( cacheKey, context.getSession().getTimestamp() ) != null;
}
return false;
}
示例10: update
import org.hibernate.EntityMode; //导入依赖的package包/类
public void update(String entityName, Object entity) {
errorIfClosed();
EntityPersister persister = getEntityPersister(entityName, entity);
Serializable id = persister.getIdentifier(entity, EntityMode.POJO);
Object[] state = persister.getPropertyValues(entity, EntityMode.POJO);
Object oldVersion;
if ( persister.isVersioned() ) {
oldVersion = persister.getVersion(entity, EntityMode.POJO);
Object newVersion = Versioning.increment( oldVersion, persister.getVersionType(), this );
Versioning.setVersion(state, newVersion, persister);
persister.setPropertyValues(entity, state, EntityMode.POJO);
}
else {
oldVersion = null;
}
persister.update(id, state, null, false, null, oldVersion, entity, null, this);
}
示例11: getSnapshot
import org.hibernate.EntityMode; //导入依赖的package包/类
public Serializable getSnapshot(CollectionPersister persister)
throws HibernateException {
EntityMode entityMode = getSession().getEntityMode();
HashMap map = new HashMap( values.size() );
Iterator iter = values.iterator();
int i=0;
while ( iter.hasNext() ) {
Object value = iter.next();
map.put(
identifiers.get( new Integer(i++) ),
persister.getElementType().deepCopy(value, entityMode, persister.getFactory())
);
}
return map;
}
示例12: deepCopy
import org.hibernate.EntityMode; //导入依赖的package包/类
public Object deepCopy(Object component, EntityMode entityMode, SessionFactoryImplementor factory)
throws HibernateException {
if ( component == null ) {
return null;
}
Object[] values = getPropertyValues( component, entityMode );
for ( int i = 0; i < propertySpan; i++ ) {
values[i] = propertyTypes[i].deepCopy( values[i], entityMode, factory );
}
Object result = instantiate( entityMode );
setPropertyValues( result, values, entityMode );
//not absolutely necessary, but helps for some
//equals()/hashCode() implementations
ComponentTuplizer ct = ( ComponentTuplizer ) tuplizerMapping.getTuplizer( entityMode );
if ( ct.hasParentProperty() ) {
ct.setParent( result, ct.getParent( component ), factory );
}
return result;
}
示例13: isCached
import org.hibernate.EntityMode; //导入依赖的package包/类
private boolean isCached(
EntityKey entityKey,
EntityPersister persister,
EntityMode entityMode) {
if ( persister.hasCache() ) {
CacheKey key = new CacheKey(
entityKey.getIdentifier(),
persister.getIdentifierType(),
entityKey.getEntityName(),
entityMode,
context.getSession().getFactory()
);
return persister.getCache().getCache().get( key ) != null;
}
return false;
}
示例14: deserialize
import org.hibernate.EntityMode; //导入依赖的package包/类
/**
* Custom deserialization routine used during deserialization of a
* Session/PersistenceContext for increased performance.
*
* @param ois The stream from which to read the entry.
* @param session The session being deserialized.
* @return The deserialized EntityEntry
* @throws IOException
* @throws ClassNotFoundException
*/
static EntityEntry deserialize(
ObjectInputStream ois,
SessionImplementor session) throws IOException, ClassNotFoundException {
return new EntityEntry(
session.getFactory(),
( String ) ois.readObject(),
( Serializable ) ois.readObject(),
EntityMode.parse( ( String ) ois.readObject() ),
Status.parse( ( String ) ois.readObject() ),
( Object[] ) ois.readObject(),
( Object[] ) ois.readObject(),
( Object ) ois.readObject(),
LockMode.parse( ( String ) ois.readObject() ),
ois.readBoolean(),
ois.readBoolean(),
ois.readBoolean()
);
}
示例15: bindMapRepresentation
import org.hibernate.EntityMode; //导入依赖的package包/类
private static void bindMapRepresentation(Element node, PersistentClass entity,
Mappings mappings, java.util.Map inheritedMetas) {
Element tuplizer = locateTuplizerDefinition( node, EntityMode.MAP );
if ( tuplizer != null ) {
entity.addTuplizer( EntityMode.MAP, tuplizer.attributeValue( "class" ) );
}
}