Package org.eclipse.persistence.internal.jpa

Examples of org.eclipse.persistence.internal.jpa.EJBQueryImpl


   * Rewrite the JPQL query string in a SQL String (The persistence provider implementation in use is EclipseLink)
   * @param query The String of the JPQL query
   * @return the string of the JPQL query translated in SQL
   */
  private String rewriteEclipseLink(String query) {
    EJBQueryImpl qi = (EJBQueryImpl) this.entityManager.createQuery(query);
    return rewriteEclipseLink(qi);
  }
View Full Code Here


   * Rewrite the JPQL query in a SQL String (The persistence provider implementation in use is EclipseLink)
   * @param query The JPQL query
   * @return the string of the JPQL query translated in SQL
   */
  private String rewriteEclipseLink(Query query) {
    EJBQueryImpl qi = (EJBQueryImpl) query;
    Session session = this.entityManager.unwrap(JpaEntityManager.class).getActiveSession();
    DatabaseQuery databaseQuery = (qi).getDatabaseQuery();
    databaseQuery.prepareCall(session, new DatabaseRecord());
    String sqlString = databaseQuery.getTranslatedSQLString(session,  new DatabaseRecord());
   
View Full Code Here

    Query q  = em.createQuery(query);
   
   
    List<String> queryParameters = new ArrayList<String>();
    queryParameters.add("USA");
    EJBQueryImpl qi = (EJBQueryImpl)q;
    String sqlQueryString = qi.getDatabaseQuery().getSQLString();
    System.out.println(sqlQueryString);
    EJBQueryImpl countQuery = (EJBQueryImpl)em.createNativeQuery("SELECT COUNT(*) FROM (" + sqlQueryString + ") temp");
    for(int i=0; i<queryParameters.size(); i++ ){
      countQuery.setParameter(1+i, queryParameters.get(i));
    }
    System.out.println("result "+countQuery.getDatabaseQuery().getSQLString());


    System.out.println(((Long)countQuery.getResultList().get(0)).intValue());

  }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.jpa.EJBQueryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.