Below is java code : TypedQuery outputSql = entityManager.createQuery(query); org.eclipse.persistence.sessions.Session session = communityEm.unwrap(org.eclipse.persistence.jpa.JpaEntityManager.class).getActiveSession(); org.eclipse.persistence.queries.DatabaseQuery databaseQuery = outputSql.unwrap(org.eclipse.persistence.jpa.JpaQuery.class).getDatabaseQuery(); databaseQuery.prepareCall(session, new org.eclipse.persistence.sessions.DatabaseRecord()); System.out.println(“databaseQuery.getSQLString()”+databaseQuery.getSQLString());
Read MoreJAVA JPA Join relations for multiple tables
E.g. we have sql below select A.id, A.name, B.name2, C.name2 from A,B,C where A.id=B.bid and B.name3 = C.id We use join to connect JPA tables // Root rootpath Entity A,B,C in B has relasionship B.name3 = C Join b_path = rootpath.join(“id”); Join c_path = b_path.join(“name3”);
Read More