本文整理匯總了Java中javax.persistence.PersistenceContextType.EXTENDED屬性的典型用法代碼示例。如果您正苦於以下問題:Java PersistenceContextType.EXTENDED屬性的具體用法?Java PersistenceContextType.EXTENDED怎麽用?Java PersistenceContextType.EXTENDED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.persistence.PersistenceContextType
的用法示例。
在下文中一共展示了PersistenceContextType.EXTENDED屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResourceToInject
/**
* Resolve the object against the application context.
*/
@Override
protected Object getResourceToInject(Object target, String requestingBeanName) {
// Resolves to EntityManagerFactory or EntityManager.
if (this.type != null) {
return (this.type == PersistenceContextType.EXTENDED ?
resolveExtendedEntityManager(target, requestingBeanName) :
resolveEntityManager(requestingBeanName));
}
else {
// OK, so we need an EntityManagerFactory...
return resolveEntityManagerFactory(requestingBeanName);
}
}
示例2: createEntityManager
public EntityManager createEntityManager(Map map) {
//TODO support discardOnClose, persistencecontexttype?, interceptor,
return new EntityManagerImpl(
this, PersistenceContextType.EXTENDED, transactionType,
discardOnClose, sessionInterceptorClass, map
);
}
示例3: setEntityManager
@PersistenceContext(type = PersistenceContextType.EXTENDED)
public void setEntityManager(EntityManager em) {
if (this.em != null) {
throw new IllegalStateException("Already called");
}
this.em = em;
}
示例4: getEntityManager
private EntityManager getEntityManager(final ExecutionContext context, final EntityManagerFactory emf) {
EntityManager em = null;
if (getPersistenceContextType(context) == PersistenceContextType.EXTENDED) {
// EntityManager may be already open. If so use it.
em = (EntityManager) context.getData(Constants.KEY_ENTITY_MANAGER);
}
if (em == null) {
// create EntityManager and inject it
em = emf.createEntityManager();
}
return em;
}
示例5: afterTest
@Override
public void afterTest(final TestInvocation invocation) throws Exception {
final ExecutionContext context = invocation.getContext();
final EntityManager em = (EntityManager) context.getData(Constants.KEY_ENTITY_MANAGER);
if (em != null && getPersistenceContextType(context) != PersistenceContextType.EXTENDED) {
context.storeData(Constants.KEY_ENTITY_MANAGER, null);
em.close();
}
}
示例6: sessionFactory
@Bean @PersistenceContext(type = PersistenceContextType.EXTENDED)
public SessionFactory sessionFactory() {
LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource());
builder.scanPackages("org.proflr.server.entity").addProperties(getHibernateProperties());
return builder.buildSessionFactory();
}
示例7: method
@PersistenceContext(name = "method", unitName = "mu", type = PersistenceContextType.EXTENDED, properties = {
@PersistenceProperty(name = "method1", value = "m1"),
@PersistenceProperty(name = "method2", value = "m2")
})
public void method() {
}
示例8: setMyMethod
@PersistenceContext(unitName = "mymu", type = PersistenceContextType.EXTENDED, properties = {
@PersistenceProperty(name = "myMethod1", value = "mym1"),
@PersistenceProperty(name = "myMethod2", value = "mym2")
})
public void setMyMethod() {
}