@Override public String extractQueryString(Query query) { return ((JpaQuery<?>) query).getDatabaseQuery().getJPQLString(); }
@Test public void testCanCastSharedEntityManagerProxyToEclipseLinkEntityManager() { assertTrue(sharedEntityManager instanceof JpaEntityManager); JpaEntityManager eclipselinkEntityManager = (JpaEntityManager) sharedEntityManager; assertNotNull(eclipselinkEntityManager.getActiveSession()); }
/** * Retrieve the shared server session from the EMF. */ public static Server getServerSession(EntityManagerFactory emf) { return getEntityManagerFactory(emf).getServerSession(); }
/** * A part of the facade over the JPA API. * Create an EntityManagerFactory using the given PersistenceUnitInfo and properties. * @param info * @param properties * @return */ protected EntityManagerFactoryImpl createEntityManagerFactory(PersistenceUnitInfo info, Map<String, ?> properties) { PersistenceProvider provider = new PersistenceProvider(); EntityManagerFactory emf = provider.createContainerEntityManagerFactory(info, properties); return (EntityManagerFactoryImpl) emf; }
/** * Gets the client session. * * @param em the em * @return the client session */ public AbstractSession getClientSession(EntityManager em) { UnitOfWork uow = JpaHelper.getEntityManager(em).getUnitOfWork(); return (AbstractSession) uow; }
/** Create a new persistence provider for unit tests. */ public static PersistenceProvider testPersistenceProvider() { return new org.eclipse.persistence.jpa.PersistenceProvider(); }
/** * Retrieve the shared database session from the EMF. */ public static DatabaseSession getDatabaseSession(EntityManagerFactory emf) { return getEntityManagerFactory(emf).getDatabaseSession(); }
/** * Retrieve the shared session broker from the EMF. */ public static SessionBroker getSessionBroker(EntityManagerFactory emf) { return getEntityManagerFactory(emf).getSessionBroker(); }
public JPADynamicHelper(EntityManager em) { super(JpaHelper.getEntityManager(em).getDatabaseSession()); }
/** * Create a EclipseLink JPA query dynamically given a EclipseLink query. */ public static Query createQuery(DatabaseQuery query, javax.persistence.EntityManager em) { return getEntityManager(em).createQuery(query); }
public MetamodelImpl(EntityManager em) { // Create a new Metamodel using the EclipseLink session on the EM this(JpaHelper.getEntityManager(em).getAbstractSession()); }
/** * Verify if the JPA provider is EclipseLink */ public static boolean isEclipseLink(EntityManagerFactory emf) { try { getEntityManagerFactory(emf); } catch (IllegalArgumentException iae) { return false; } return true; }
/** * Gets the jpa server session. * * @return the jpa server session */ public DatabaseSession getServerSession() { // Fix for bug 390786 - JPA-RS: ClassCastException retrieving metadata for Composite Persistence Unit return JpaHelper.getDatabaseSession(emf); }
/** * Verify if the JPA provider is EclipseLink. If you are in a container * and not in a transaction this method may incorrectly return false. * It is always more reliable to check isEclipseLink on the EMF or Query. */ public static boolean isEclipseLink(javax.persistence.EntityManager em) { return getEntityManager(em) != null; }
@Override public TypedQuery<T> setMaxResults(int maxResults) { this.maxResults = maxResults; if (query != null) query.setMaxResults(maxResults); return this; }
public void apply(JpaQuery query) { if (temporalType != null) { if (name instanceof Integer) query.setParameter((int) name, (Date) value, temporalType); else query.setParameter((String) name, (Date) value, temporalType); } else { if (name instanceof Integer) query.setParameter((int) name, value); else query.setParameter((String) name, value); } }
@Override public TypedQuery<T> setFirstResult(int firstResult) { this.firstResult = firstResult; if (query != null) query.setFirstResult(firstResult); return this; }
/** * A part of the facade over the JPA API. * Create an EntityManagerFactory using the given PersistenceUnitInfo and properties. * @param info * @param properties * @return */ protected EntityManagerFactoryImpl createEntityManagerFactory(PersistenceUnitInfo info, Map<String, ?> properties) { PersistenceProvider provider = new PersistenceProvider(); EntityManagerFactory emf = provider.createContainerEntityManagerFactory(info, properties); return (EntityManagerFactoryImpl) emf; }
/** * Gets the client session. * * @param em the em * @return the client session */ public AbstractSession getClientSession(EntityManager em) { UnitOfWork uow = JpaHelper.getEntityManager(em).getUnitOfWork(); return (AbstractSession) uow; }
/** * Gets the jpa server session. * * @return the jpa server session */ public DatabaseSession getServerSession() { // Fix for bug 390786 - JPA-RS: ClassCastException retrieving metadata for Composite Persistence Unit return JpaHelper.getDatabaseSession(emf); }