本文整理汇总了Java中org.hibernate.jpa.HibernateEntityManager类的典型用法代码示例。如果您正苦于以下问题:Java HibernateEntityManager类的具体用法?Java HibernateEntityManager怎么用?Java HibernateEntityManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HibernateEntityManager类属于org.hibernate.jpa包,在下文中一共展示了HibernateEntityManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: delegatesToUnwrapForNonProxyClass
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
@Test
public void delegatesToUnwrapForNonProxyClass() {
HibernateEntityManager mockHibernateEm = mock(HibernateEntityManager.class);
when(entityManager.unwrap(HibernateEntityManager.class)).thenReturn(mockHibernateEm);
HibernateEntityManager foundHibernateEm = createProxy().unwrap(HibernateEntityManager.class);
verify(entityManager).unwrap(HibernateEntityManager.class);
assertThat(foundHibernateEm).isSameAs(mockHibernateEm);
}
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:10,代码来源:SharedEntityManagerFactoryTest.java
示例2: logStats
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
/**
* Log stats.
*
* @param comment
* the comment
*/
public void logStats(final String comment) {
if (entityManager instanceof HibernateEntityManager) {
final Session session = ((HibernateEntityManager) entityManager).getSession();
logger.info("STATS: " + comment);
session.getSessionFactory().getStatistics().logSummary();
} else {
logger.warn("Entity Manager is not a hibernate entity manager");
}
}
开发者ID:biomojo,项目名称:biomojo,代码行数:16,代码来源:DbUtil.java
示例3: Managed
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
public Managed(EntityManagerFactory emf) {
session = emf.createEntityManager().unwrap(HibernateEntityManager.class).getSession();
}
开发者ID:Juraji,项目名称:Biliomi,代码行数:4,代码来源:Managed.java
示例4: MockEntityManagerProvider
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
private MockEntityManagerProvider() {
this.entityManager = Mockito.mock(HibernateEntityManager.class);
this.entityManagerFactory = Mockito.mock(HibernateEntityManagerFactory.class);
this.metamodel = Mockito.mock(Metamodel.class);
}
开发者ID:kuros,项目名称:random-jpa,代码行数:6,代码来源:MockEntityManagerProvider.java
示例5: Builder
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
public Builder(final HibernateEntityManager entityManager) {
this.sessionFactory = null;
this.isScrollEnabled = true;
this.scrollMode = ScrollMode.FORWARD_ONLY;
this.entityManager = entityManager;
}
开发者ID:yahoo,项目名称:elide,代码行数:7,代码来源:AbstractHibernateStore.java
示例6: HibernateEntityManagerStore
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
public HibernateEntityManagerStore(HibernateEntityManager entityManager,
boolean isScrollEnabled,
ScrollMode scrollMode) {
super(null, isScrollEnabled, scrollMode);
this.entityManager = entityManager;
}
开发者ID:yahoo,项目名称:elide,代码行数:7,代码来源:HibernateEntityManagerStore.java
示例7: configureSession
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
private void configureSession() {
HibernateEntityManager em = (HibernateEntityManager) this.entityManager;
em.getSession().setDefaultReadOnly(this.unitOfWork.readOnly());
em.getSession().setCacheMode(this.unitOfWork.cacheMode());
em.getSession().setFlushMode(this.unitOfWork.flushMode());
}
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:7,代码来源:UnitOfWorkAspect.java
示例8: saveFileAttribute
import org.hibernate.jpa.HibernateEntityManager; //导入依赖的package包/类
public PersistedFileAttribute saveFileAttribute(ClientSession session, FileItem fileItem, String forClassName, String forAttributeName, Integer forInstanceID) {
PersistedFileAttribute pfa = null;
EntityManager em = null;
EntityTransaction tx = null;
try {
em = AtomEMFactory.getEntityManager();
tx = em.getTransaction();
tx.begin();
DomainObject forInstance = null;
if(forInstanceID != null) {
//forInstance = getDomainObject(session, forInstanceID, forClassName);
forInstance = (DomainObject) em.find(ServerTools.getClassForName(forClassName), forInstanceID);
}
HibernateEntityManager hem = em.unwrap(HibernateEntityManager.class);
Session hibernateSession = hem.getSession();
LobCreator lobCreator = Hibernate.getLobCreator(hibernateSession);
Blob blob = lobCreator.createBlob(fileItem.getInputStream(), fileItem.getSize());
pfa = new PersistedFileAttribute(blob, fileItem.getName(), fileItem.getContentType(), forClassName, forAttributeName, forInstance, session.getUser());
pfa = em.merge(pfa);
tx.commit();
} catch (Throwable t) {
if(tx != null && tx.isActive())
tx.rollback();
if (t instanceof AtomException) {
throw (AtomException) t;
} else {
AtomTools.log(Level.SEVERE, "ServerTools.saveFileAttribute exception: " + t.getClass().getSimpleName() + " - " + t.getMessage(), this, t);
}
} finally {
ServerTools.closeDBConnection(tx, em);
}
return pfa;
}
开发者ID:fhcampuswien,项目名称:atom,代码行数:42,代码来源:ServerSingleton.java
注:本文中的org.hibernate.jpa.HibernateEntityManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论