Java 类javax.persistence.PersistenceContextType 实例源码
项目:lams
文件:PersistenceAnnotationBeanPostProcessor.java
/**
* 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);
}
}
项目:helium
文件:EntityManagerFactoryImpl.java
public EntityManager createEntityManager(Map map) {
//TODO support discardOnClose, persistencecontexttype?, interceptor,
return new EntityManagerImpl(
this, PersistenceContextType.EXTENDED, transactionType,
discardOnClose, sessionInterceptorClass, map
);
}
项目:spring4-understanding
文件:PersistenceAnnotationBeanPostProcessor.java
/**
* 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);
}
}
项目:spring4-understanding
文件:PersistenceInjectionTests.java
@PersistenceContext(type = PersistenceContextType.EXTENDED)
public void setEntityManager(EntityManager em) {
if (this.em != null) {
throw new IllegalStateException("Already called");
}
this.em = em;
}
项目:jpa-unit
文件:PersistenceContextDecorator.java
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;
}
项目:jpa-unit
文件:PersistenceContextDecorator.java
@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();
}
}
项目:proflr-server
文件:Application.java
@Bean @PersistenceContext(type = PersistenceContextType.EXTENDED)
public SessionFactory sessionFactory() {
LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource());
builder.scanPackages("org.proflr.server.entity").addProperties(getHibernateProperties());
return builder.buildSessionFactory();
}
项目:class-guard
文件:PersistenceAnnotationBeanPostProcessor.java
/**
* 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);
}
}
项目:class-guard
文件:PersistenceInjectionTests.java
@PersistenceContext(type = PersistenceContextType.EXTENDED)
public void setEntityManager(EntityManager em) {
if (this.em != null) {
throw new IllegalStateException("Already called");
}
this.em = em;
}
项目:testee.fi
文件:JpaInjectionServicesTest.java
private InjectionPoint persistenceContext(String unitName) {
final InjectionPoint ip = mock(InjectionPoint.class);
final Annotated annotated = mock(Annotated.class);
when(ip.getAnnotated()).thenReturn(annotated);
final PersistenceContext annotation = new PersistenceContext() {
@Override
public Class<? extends Annotation> annotationType() {
return null;
}
@Override
public String name() {
return null;
}
@Override
public String unitName() {
return unitName;
}
@Override
public PersistenceContextType type() {
return null;
}
@Override
public SynchronizationType synchronization() {
return null;
}
@Override
public PersistenceProperty[] properties() {
return new PersistenceProperty[0];
}
};
when(annotated.getAnnotation(PersistenceContext.class)).thenReturn(annotation);
return ip;
}
项目:spring4-understanding
文件:PersistenceInjectionTests.java
@Override
@PersistenceContext(unitName="unit2", type = PersistenceContextType.EXTENDED)
public void setEntityManager(EntityManager em) {
super.setEntityManager(em);
}
项目:jpa-unit
文件:PersistenceContextDecorator.java
private PersistenceContextType getPersistenceContextType(final ExecutionContext context) {
final Field field = context.getPersistenceField();
final PersistenceContext pc = field.getAnnotation(PersistenceContext.class);
return pc.type();
}
项目:tapestry-jpa-transactions
文件:PersistenceContextImpl.java
@Override
public PersistenceContextType type()
{
return PersistenceContextType.TRANSACTION;
}
项目:switchyard
文件:EntityManagerImpl.java
public EntityManagerImpl(EntityManagerFactoryImpl entityManagerFactory, PersistenceContextType pcType, SynchronizationType synchronizationType, PersistenceUnitTransactionType transactionType, boolean discardOnClose, Class sessionInterceptorClass, Map properties) {
super(entityManagerFactory, pcType, synchronizationType, transactionType, discardOnClose, sessionInterceptorClass, properties);
}
项目:class-guard
文件:PersistenceInjectionTests.java
@Override
@PersistenceContext(unitName="unit2", type = PersistenceContextType.EXTENDED)
public void setEntityManager(EntityManager em) {
super.setEntityManager(em);
}
项目:tomee
文件:PersistenceContextAnnFactoryTest.java
@PersistenceContext(name = "method", unitName = "mu", type = PersistenceContextType.EXTENDED, properties = {
@PersistenceProperty(name = "method1", value = "m1"),
@PersistenceProperty(name = "method2", value = "m2")
})
public void method() {
}
项目:tomee
文件:PersistenceContextAnnFactoryTest.java
@PersistenceContext(unitName = "mymu", type = PersistenceContextType.EXTENDED, properties = {
@PersistenceProperty(name = "myMethod1", value = "mym1"),
@PersistenceProperty(name = "myMethod2", value = "mym2")
})
public void setMyMethod() {
}