PersisterFactorypublic final class PersisterFactory extends Object Factory for EntityPersister and CollectionPersister instances |
Fields Summary |
---|
private static final Class[] | PERSISTER_CONSTRUCTOR_ARGS | private static final Class[] | COLLECTION_PERSISTER_CONSTRUCTOR_ARGS |
Constructors Summary |
---|
private PersisterFactory()
|
Methods Summary |
---|
private static org.hibernate.persister.entity.EntityPersister | create(java.lang.Class persisterClass, org.hibernate.mapping.PersistentClass model, org.hibernate.cache.CacheConcurrencyStrategy cache, org.hibernate.engine.SessionFactoryImplementor factory, org.hibernate.engine.Mapping cfg)
Constructor pc;
try {
pc = persisterClass.getConstructor(PERSISTER_CONSTRUCTOR_ARGS);
}
catch (Exception e) {
throw new MappingException( "Could not get constructor for " + persisterClass.getName(), e );
}
try {
return (EntityPersister) pc.newInstance( new Object[] { model, cache, factory, cfg } );
}
catch (InvocationTargetException ite) {
Throwable e = ite.getTargetException();
if (e instanceof HibernateException) {
throw (HibernateException) e;
}
else {
throw new MappingException( "Could not instantiate persister " + persisterClass.getName(), e );
}
}
catch (Exception e) {
throw new MappingException( "Could not instantiate persister " + persisterClass.getName(), e );
}
| private static org.hibernate.persister.collection.CollectionPersister | create(java.lang.Class persisterClass, org.hibernate.cfg.Configuration cfg, org.hibernate.mapping.Collection model, org.hibernate.cache.CacheConcurrencyStrategy cache, org.hibernate.engine.SessionFactoryImplementor factory)
Constructor pc;
try {
pc = persisterClass.getConstructor(COLLECTION_PERSISTER_CONSTRUCTOR_ARGS);
}
catch (Exception e) {
throw new MappingException( "Could not get constructor for " + persisterClass.getName(), e );
}
try {
return (CollectionPersister) pc.newInstance( new Object[] { model, cache, cfg, factory } );
}
catch (InvocationTargetException ite) {
Throwable e = ite.getTargetException();
if (e instanceof HibernateException) {
throw (HibernateException) e;
}
else {
throw new MappingException( "Could not instantiate collection persister " + persisterClass.getName(), e );
}
}
catch (Exception e) {
throw new MappingException( "Could not instantiate collection persister " + persisterClass.getName(), e );
}
| public static org.hibernate.persister.entity.EntityPersister | createClassPersister(org.hibernate.mapping.PersistentClass model, org.hibernate.cache.CacheConcurrencyStrategy cache, org.hibernate.engine.SessionFactoryImplementor factory, org.hibernate.engine.Mapping cfg)
Class persisterClass = model.getEntityPersisterClass();
if (persisterClass==null || persisterClass==SingleTableEntityPersister.class) {
return new SingleTableEntityPersister(model, cache, factory, cfg);
}
else if (persisterClass==JoinedSubclassEntityPersister.class) {
return new JoinedSubclassEntityPersister(model, cache, factory, cfg);
}
else if (persisterClass==UnionSubclassEntityPersister.class) {
return new UnionSubclassEntityPersister(model, cache, factory, cfg);
}
else {
return create(persisterClass, model, cache, factory, cfg);
}
| public static org.hibernate.persister.collection.CollectionPersister | createCollectionPersister(org.hibernate.cfg.Configuration cfg, org.hibernate.mapping.Collection model, org.hibernate.cache.CacheConcurrencyStrategy cache, org.hibernate.engine.SessionFactoryImplementor factory)
Class persisterClass = model.getCollectionPersisterClass();
if(persisterClass==null) { // default behavior
return model.isOneToMany() ?
(CollectionPersister) new OneToManyPersister(model, cache, cfg, factory) :
(CollectionPersister) new BasicCollectionPersister(model, cache, cfg, factory);
}
else {
return create(persisterClass, cfg, model, cache, factory);
}
|
|