{"id":1580,"date":"2012-07-05T10:00:00","date_gmt":"2012-07-05T10:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/test-jpql-hql-without-a-deploy.html"},"modified":"2012-10-22T06:09:44","modified_gmt":"2012-10-22T06:09:44","slug":"test-jpql-hql-without-deploy","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html","title":{"rendered":"Test JPQL \/ HQL without a deploy"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application?<br \/>\nWhat we will see here today is simple solution that works for any JPA implementation: Hibernate, OpenJPA, EclipseLink and others.            <\/p>\n<p>The base source code found in this post came from this book: \u201c<i>Pro JPA 2: Mastering the Java\u2122 Persistence API \u2013 Mike Keith, Merrick Schincariol<\/i>\u201d. This post will add to the original code: query parameters and NamedQuery test. <\/p>\n<p><strong>Model classes and data Generation<\/strong><\/p>\n<p>Bellow are the model classes\u2019 code:            <\/p>\n<pre class=\"brush:java\">package com.model;\r\n\r\nimport java.util.*;\r\n\r\nimport javax.persistence.*;\r\n\r\n@Entity\r\n@NamedQueries({\r\n  @NamedQuery(name=\"Person.findByName\", query=\"select p from Person p where p.name = :name\"),\r\n  @NamedQuery(name=\"Person.findByAge\", query=\"select p from Person p where p.age = :age\", hints={@QueryHint(name=\"org.hibernate.timeout\", value=\"1000\")})\r\n})\r\n\r\npublic class Person {\r\n\r\n public static final String FIND_BY_NAME = \"Person.findByName\";\r\n public static final String FIND_BY_AGE = \"Person.findByAge\";\r\n\r\n @Id\r\n @GeneratedValue(strategy = GenerationType.AUTO)\r\n private int id;\r\n\r\n private String name;\r\n private int age;\r\n\r\n public Person() {\r\n\r\n }\r\n\r\n public Person(int id) {\r\n  this.id = id;\r\n }\r\n\r\n public Person(String name, int age) {\r\n  this.name = name;\r\n  this.age = age;\r\n }\r\n\r\n @OneToMany(mappedBy = \"person\", cascade = CascadeType.ALL)\r\n private List&lt;Dog&gt; dogs;\r\n\r\n @OneToOne(cascade = CascadeType.ALL)\r\n @JoinColumn(name=\"address_id\")\r\n private Address address;\r\n\r\n public int getId() {\r\n  return id;\r\n }\r\n\r\n public void setId(int id) {\r\n  this.id = id;\r\n }\r\n\r\n public String getName() {\r\n  return name;\r\n }\r\n\r\n public void setName(String name) {\r\n  this.name = name;\r\n }\r\n\r\n public int getAge() {\r\n  return age;\r\n }\r\n\r\n public void setAge(int age) {\r\n  this.age = age;\r\n }\r\n\r\n public List&lt;Dog&gt; getDogs() {\r\n  if (dogs == null) {\r\n   dogs = new ArrayList&lt;Dog&gt;();\r\n  }\r\n\r\n  return dogs;\r\n }\r\n\r\n public void setDogs(List&lt;Dog&gt; dogs) {\r\n  this.dogs = dogs;\r\n }\r\n\r\n public Address getAddress() {\r\n  return address;\r\n }\r\n\r\n public void setAddress(Address address) {\r\n  this.address = address;\r\n }\r\n\r\n @Override\r\n public int hashCode() {\r\n  return getId();\r\n }\r\n\r\n @Override\r\n public boolean equals(Object obj) {\r\n  if (obj instanceof Person) {\r\n   Person person = (Person) obj;\r\n   return person.getId() == getId();\r\n  }\r\n\r\n  return false;\r\n }\r\n\r\n @Override\r\n public String toString() {\r\n  return \"Person name: \" + name;\r\n }\r\n}<\/pre>\n<pre class=\"brush:java\">package com.model;\r\n\r\nimport java.util.Date;\r\n\r\nimport javax.persistence.*;\r\n\r\n@Entity\r\n@NamedQueries(value={@NamedQuery(name=\"Dog.FindByDateOfBirth\", query=\"select d from Dog d where d.dateOfBirth = :dateOfBirth\"),\r\n  @NamedQuery(name=\"Dog.FindByPerson\", query=\"select d from Dog d where d.person = :personObject\")})\r\npublic class Dog {\r\n\r\n public static final String FIND_BY_DATE_OF_BIRTH = \"Dog.FindByDateOfBirth\";\r\n\r\n @Id\r\n @GeneratedValue(strategy = GenerationType.AUTO)\r\n private int id;\r\n\r\n private String name;\r\n private double weight;\r\n\r\n @Temporal(TemporalType.TIMESTAMP)\r\n private Date dateOfBirth;\r\n\r\n public Dog() {\r\n\r\n }\r\n\r\n public Dog(String name, double weight, Date dateOfBirth) {\r\n  this.name = name;\r\n  this.weight = weight;\r\n  this.dateOfBirth = dateOfBirth;\r\n }\r\n\r\n public static void main(String[] args) {\r\n\r\n  System.out.println(new Date());\r\n }\r\n\r\n @ManyToOne\r\n private Person person;\r\n\r\n public int getId() {\r\n  return id;\r\n }\r\n\r\n public void setId(int id) {\r\n  this.id = id;\r\n }\r\n\r\n public String getName() {\r\n  return name;\r\n }\r\n\r\n public void setName(String name) {\r\n  this.name = name;\r\n }\r\n\r\n public double getWeight() {\r\n  return weight;\r\n }\r\n\r\n public void setWeight(double weight) {\r\n  this.weight = weight;\r\n }\r\n\r\n public Date getDateOfBirth() {\r\n  return dateOfBirth;\r\n }\r\n\r\n public void setDateOfBirth(Date dateOfBirth) {\r\n  this.dateOfBirth = dateOfBirth;\r\n }\r\n\r\n public Person getPerson() {\r\n  return person;\r\n }\r\n\r\n public void setPerson(Person person) {\r\n  this.person = person;\r\n }\r\n\r\n @Override\r\n public int hashCode() {\r\n  return getId();\r\n }\r\n\r\n @Override\r\n public boolean equals(Object obj) {\r\n  if (obj instanceof Dog) {\r\n   Dog dog = (Dog) obj;\r\n   return dog.getId() == getId();\r\n  }\r\n\r\n  return false;\r\n }\r\n\r\n @Override\r\n public String toString() {\r\n  return \"Dog name: \" + name;\r\n }\r\n}<\/pre>\n<pre class=\"brush:java\">package com.model;\r\n\r\nimport javax.persistence.*;\r\n\r\n@Entity\r\n@NamedQuery(name=\"Address.FindAll\", query=\"select a from Address a\")\r\npublic class Address {\r\n\r\n @Id\r\n @GeneratedValue(strategy = GenerationType.AUTO)\r\n private int id;\r\n\r\n private String streetName;\r\n private int houseNumber;\r\n\r\n public Address() {\r\n\r\n }\r\n\r\n public Address(String streetName, int houseNumber) {\r\n  this.streetName = streetName;\r\n  this.houseNumber = houseNumber;\r\n }\r\n\r\n public int getId() {\r\n  return id;\r\n }\r\n\r\n public void setId(int id) {\r\n  this.id = id;\r\n }\r\n\r\n public String getStreetName() {\r\n  return streetName;\r\n }\r\n\r\n public void setStreetName(String streetName) {\r\n  this.streetName = streetName;\r\n }\r\n\r\n public int getHouseNumber() {\r\n  return houseNumber;\r\n }\r\n\r\n public void setHouseNumber(int houseNumber) {\r\n  this.houseNumber = houseNumber;\r\n }\r\n\r\n @Override\r\n public int hashCode() {\r\n  return getId();\r\n }\r\n\r\n @Override\r\n public boolean equals(Object obj) {\r\n  if (obj instanceof Address) {\r\n   Address address = (Address) obj;\r\n   return address.getId() == getId();\r\n  }\r\n\r\n  return false;\r\n }\r\n\r\n @Override\r\n public String toString() {\r\n  return \"Adress street name: \" + streetName;\r\n }\r\n}<\/pre>\n<p>In the code above we got several JPA relationships as a sample.            <\/p>\n<p>Bellow is the class that will handle the transaction and the data that will be written into the HSQLDB database:            <\/p>\n<pre class=\"brush:java\">package com.main;\r\n\r\nimport java.text.*;\r\nimport java.util.Date;\r\n\r\nimport javax.persistence.*;\r\n\r\nimport com.model.*;\r\n\r\npublic class CodeGenerator {\r\n private static EntityManagerFactory emf;\r\n private static EntityManager em;\r\n\r\n public static final String PERSON01_NAME = \"John\";\r\n public static final String PERSON02_NAME = \"Mary\";\r\n public static final String PERSON03_NAME = \"Anna\";\r\n public static final String PERSON04_NAME = \"Joseph\";\r\n public static final String PERSON05_NAME = \"Mark\";\r\n public static final String PERSON06_NAME = \"I will not have any relationship\";\r\n\r\n public static void startConnection() {\r\n  emf = Persistence.createEntityManagerFactory(\"QueryTester\");\r\n  em = emf.createEntityManager();\r\n  em.getTransaction().begin();\r\n }\r\n\r\n public static void closeConnection() {\r\n  em.getTransaction().commit();\r\n  emf.close();\r\n }\r\n\r\n public static void generateData() {\r\n  int year = 1995;\r\n  int month = 1;\r\n  int day = 10;\r\n\r\n  Dog dog01 = new Dog(\"Yellow\", 3.5d, createNewDate(day, month, year));\r\n  Dog dog02 = new Dog(\"Brown\", 8.5d, createNewDate(++day, ++month, ++year));\r\n  Dog dog03 = new Dog(\"Dark\", 15.5d, createNewDate(++day, ++month, ++year));\r\n  Dog dog04 = new Dog(\"Kaka\", 4.3d, createNewDate(++day, ++month, ++year));\r\n  Dog dog05 = new Dog(\"Pepe\", 8.2d, createNewDate(++day, ++month, ++year));\r\n  Dog dog06 = new Dog(\"Casillas\", 6.1d, createNewDate(++day, ++month, ++year));\r\n  Dog dog07 = new Dog(\"Fish\", 6.7d, createNewDate(++day, ++month, ++year));\r\n  Dog dog08 = new Dog(\"Lion\", 3.1d, createNewDate(++day, ++month, ++year));\r\n  Dog dog09 = new Dog(\"Cat\", 5.5d, createNewDate(++day, ++month, ++year));\r\n  Dog dog10 = new Dog(\"Java\", 21.7d, createNewDate(++day, ++month, ++year));\r\n  Dog dog11 = new Dog(\"JSF\", 23.65d, createNewDate(++day, ++month, ++year));\r\n  Dog dog12 = new Dog(\"VRaptor\", 24.0d, createNewDate(++day, ++month, ++year));\r\n  Dog dog13 = new Dog(\"Ferrari\", 3.7d, createNewDate(++day, ++month, ++year));\r\n  Dog dog14 = new Dog(\"Porshe\", 1.33d, createNewDate(++day, ++month, ++year));\r\n  Dog dog15 = new Dog(\"Bike\", 4.44d, createNewDate(++day, ++month, ++year));\r\n  Dog dog16 = new Dog(\"Rambo\", 5.44d, createNewDate(++day, ++month, 2015));\r\n  Dog dog17 = new Dog(\"Terminator\", 3.88d, createNewDate(++day, ++month, 2016));\r\n  Dog dog18 = new Dog(\"John McClan\", 3.88d, createNewDate(++day, ++month, 2016));\r\n\r\n  Person person01 = new Person(PERSON01_NAME, 33);\r\n  person01.getDogs().add(dog01);\r\n  person01.getDogs().add(dog02);\r\n  person01.getDogs().add(dog03);\r\n  person01.setAddress(new Address(\"Street A\", 30));\r\n  dog01.setPerson(person01);\r\n  dog02.setPerson(person01);\r\n  dog03.setPerson(person01);\r\n\r\n  Person person02 = new Person(PERSON02_NAME, 27);\r\n  person02.getDogs().add(dog04);\r\n  person02.getDogs().add(dog05);\r\n  person02.getDogs().add(dog06);\r\n  person02.setAddress(new Address(\"Street B\", 60));\r\n  dog04.setPerson(person02);\r\n  dog05.setPerson(person02);\r\n  dog06.setPerson(person02);\r\n\r\n  Person person03 = new Person(PERSON03_NAME, 7);\r\n  person03.getDogs().add(dog07);\r\n  person03.getDogs().add(dog08);\r\n  person03.getDogs().add(dog09);\r\n  person03.setAddress(new Address(\"Street B\", 90));\r\n  dog07.setPerson(person03);\r\n  dog08.setPerson(person03);\r\n  dog09.setPerson(person03);\r\n\r\n  Person person04 = new Person(PERSON04_NAME, 43);\r\n  person04.getDogs().add(dog10);\r\n  person04.getDogs().add(dog11);\r\n  person04.getDogs().add(dog12);\r\n  person04.setAddress(new Address(\"Street C\", 120));\r\n  dog10.setPerson(person04);\r\n  dog11.setPerson(person04);\r\n  dog12.setPerson(person04);\r\n\r\n  Person person05 = new Person(PERSON05_NAME, 70);\r\n  person05.getDogs().add(dog13);\r\n  person05.getDogs().add(dog14);\r\n  person05.getDogs().add(dog15);\r\n  person05.getDogs().add(dog16);\r\n  person05.setAddress(new Address(\"Street D\", 150));\r\n  dog13.setPerson(person05);\r\n  dog14.setPerson(person05);\r\n  dog15.setPerson(person05);\r\n  dog16.setPerson(person05);\r\n\r\n  Person person06 = new Person(PERSON06_NAME, 45);\r\n\r\n  em.persist(person01);\r\n  em.persist(person02);\r\n  em.persist(person03);\r\n  em.persist(person04);\r\n  em.persist(person05);\r\n  em.persist(person06);\r\n\r\n  em.persist(dog17);\r\n  em.persist(dog18);\r\n\r\n  em.flush();\r\n }\r\n\r\n private static Date createNewDate(int day, int month, int year) {\r\n  SimpleDateFormat formatter = new SimpleDateFormat(\"dd\/MM\/yyyy\");\r\n  try {\r\n   return formatter.parse(\"\" + day + \"\/\" + month + \"\/\" + year);\r\n  } catch (ParseException e) {\r\n   e.printStackTrace();\r\n   return null;\r\n  }\r\n }\r\n\r\n public static EntityManager getEntityManager() {\r\n  return em;\r\n }\r\n}<\/pre>\n<p>The \u201cpersistence.xml\u201d file can be found in the \u201csrc\/META-INF\u201d folder with the code bellow:            <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n\r\n&lt;persistence version=\"2.0\"\r\n xmlns=\"http:\/\/java.sun.com\/xml\/ns\/persistence\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/persistence http:\/\/java.sun.com\/xml\/ns\/persistence\/persistence_2_0.xsd\"&gt;\r\n\r\n &lt;persistence-unit name=\"QueryTester\"\r\n  transaction-type=\"RESOURCE_LOCAL\"&gt;\r\n  &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;\/provider&gt;\r\n\r\n  &lt;properties&gt;\r\n   &lt;property name=\"javax.persistence.jdbc.driver\" value=\"org.hsqldb.jdbcDriver\" \/&gt;\r\n   &lt;property name=\"javax.persistence.jdbc.url\" value=\"jdbc:hsqldb:mem:.\" \/&gt;\r\n   &lt;property name=\"javax.persistence.jdbc.user\" value=\"sa\" \/&gt;\r\n   &lt;property name=\"javax.persistence.jdbc.password\" value=\"\" \/&gt;\r\n   &lt;property name=\"hibernate.dialect\" value=\"org.hibernate.dialect.HSQLDialect\" \/&gt;\r\n   &lt;property name=\"hibernate.connection.shutdown\" value=\"true\" \/&gt;\r\n   &lt;property name=\"hibernate.hbm2ddl.auto\" value=\"update\" \/&gt;\r\n   &lt;property name=\"hibernate.show_sql\" value=\"false\" \/&gt;\r\n            &lt;property name=\"hibernate.format_sql\" value=\"false\"\/&gt;\r\n  &lt;\/properties&gt;\r\n &lt;\/persistence-unit&gt;\r\n&lt;\/persistence&gt;<\/pre>\n<p><strong>Abstract test class<\/strong>   <\/p>\n<pre class=\"brush:java\">package com.main;\r\n\r\nimport javax.persistence.Query;\r\n\r\nimport org.apache.commons.lang3.builder.ReflectionToStringBuilder;\r\nimport org.apache.commons.lang3.builder.ToStringStyle;\r\n\r\nimport com.model.Person;\r\n\r\n\/**\r\n * @author Pro JPA 2 book\r\n * @Empowered by uaiHebert\r\n * \r\n *\/\r\npublic abstract class AbstractQueryTester {\r\n\r\n protected static void populateParameters(Query query, String parameters) {\r\n  for (String parameter : parameters.split(\";\")) {\r\n   String parameterKey = parameter.split(\"-\")[0];\r\n   String parameterValue = parameter.split(\"-\")[1];\r\n   String parameterType = parameter.split(\"-\")[2];\r\n\r\n   query.setParameter(parameterKey, configureParameterValue(parameterValue, parameterType));\r\n  }\r\n }\r\n\r\n private static Object configureParameterValue(String parameterValue, String parameterType) {\r\n  if (parameterType.equalsIgnoreCase(\"integer\")) {\r\n   try {\r\n    return Integer.parseInt(parameterValue);\r\n   } catch (Exception e) {\r\n    throw new IllegalArgumentException(\"Invalid parameter value as number: \" + parameterValue);\r\n   }\r\n  }\r\n\r\n  if (parameterType.equalsIgnoreCase(\"string\")) {\r\n   return parameterValue;\r\n  }\r\n\r\n  if (parameterType.equalsIgnoreCase(\"person\")) {\r\n   int personId;\r\n\r\n   try {\r\n    personId = Integer.valueOf(parameterValue);\r\n   } catch (Exception e) {\r\n    throw new IllegalArgumentException(\"Invalid parameter value as number: \" + parameterValue);\r\n   }\r\n\r\n   return new Person(personId);\r\n  }\r\n\r\n  throw new IllegalArgumentException(\"Invalid parameter type: \" + parameterType);\r\n }\r\n\r\n protected static void printResult(Object result) throws Exception {\r\n  if (result == null) {\r\n   System.out.print(\"NULL\");\r\n  } else if (result instanceof Object[]) {\r\n   Object[] row = (Object[]) result;\r\n   System.out.print(\"[\");\r\n   for (int i = 0; i &lt; row.length; i++) {\r\n    printResult(row[i]);\r\n   }\r\n   System.out.print(\"]\");\r\n  } else if (result instanceof Long || result instanceof Double || result instanceof String) {\r\n   System.out.print(result.getClass().getName() + \": \" + result);\r\n  } else {\r\n   System.out.print(ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));\r\n  }\r\n\r\n  System.out.println();\r\n } \r\n}<\/pre>\n<p>About the above code:            <\/p>\n<ul>\n<li>The populateParameters method will populate all query parameters automatically. The Eclipse console will require that the developer type the Query information and the Query parameters if any is required. The Query parameters should follow the syntax requirements bellow:\n<ul>\n<li>0 parameters: just press \u201cEnter\u201d<\/li>\n<li>1 parameter: id-4-integer<\/li>\n<li>2 or more parameters:  name-John-string;age-33-integer<\/li>\n<li>The developer may use class as parameter: dog-33-Dog<\/li>\n<\/ul>\n<\/li>\n<li>The configureParameterValue method will \u201ccast\u201d the parameterValue to the correct type required by the Query. It allows primitive values and classes.<\/li>\n<li>The printResult method will display the Query result.<\/li>\n<\/ul>\n<p><strong>Dynamic Query test<\/strong><\/p>\n<pre class=\"brush:java\">package com.main;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\nimport java.util.List;\r\n\r\nimport javax.persistence.EntityManager;\r\nimport javax.persistence.Query;\r\n\r\n\/**\r\n * @author Pro JPA 2 book\r\n * @Empowered by uaiHebert\r\n * \r\n *\/\r\npublic class DynamicQueryTester extends AbstractQueryTester {\r\n public static void main(String[] args) throws IOException {\r\n  CodeGenerator.startConnection();\r\n\r\n  CodeGenerator.generateData();\r\n\r\n  EntityManager em = CodeGenerator.getEntityManager();\r\n\r\n  BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n  for (;;) {\r\n   System.out.print(\"Type your JPQL and press Enter &gt; \");\r\n   String dynamicQuery = reader.readLine();\r\n\r\n   if (dynamicQuery.equals(\"quit\")) {\r\n    break;\r\n   }\r\n\r\n   if (dynamicQuery.length() == 0) {\r\n    continue;\r\n   }\r\n\r\n   System.out.println(\"Type the namedQuery parameters.\");\r\n   System.out.println(\"All paramters should be like: id-2-integer;name-John-string\");\r\n   System.out.println(\"Or just press enter for 0 parameters\");\r\n   String parameters = reader.readLine();\r\n\r\n   try {\r\n    Query query = em.createQuery(dynamicQuery);\r\n\r\n    if (parameters.length() &gt; 0) {\r\n     populateParameters(query, parameters);\r\n    }\r\n\r\n    @SuppressWarnings(\"rawtypes\")\r\n    List result = query.getResultList();\r\n\r\n    if (result.size() &gt; 0) {\r\n     int count = 0;\r\n     for (Object o : result) {\r\n      System.out.print(++count + \" \");\r\n      printResult(o);\r\n     }\r\n    } else {\r\n     System.out.println(\"0 results returned\");\r\n    }\r\n   } catch (Exception e) {\r\n    e.printStackTrace();\r\n   }\r\n  }\r\n\r\n  CodeGenerator.closeConnection();\r\n }\r\n}<\/pre>\n<p>The code above will start a transaction, create the database data in runtime memory and allow a developer to test any kind of dynamic query. To test a JPQL \/ HQL the developer just need to type the Query code in the console.            <\/p>\n<p>To finish the loop do not type any Query data, just type \u201cquit\u201d and press \u201cEnter\u201d. <\/p>\n<p><strong>NamedQuery test<\/strong><br \/>\n<strong>&nbsp;<\/strong>         <\/p>\n<pre class=\"brush:java\">package com.main;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\nimport java.util.List;\r\n\r\nimport javax.persistence.EntityManager;\r\nimport javax.persistence.Query;\r\n\r\n\/**\r\n * @author Pro JPA 2 book\r\n * @Empowered by uaiHebert\r\n * \r\n *\/\r\npublic class NamedQueryTester extends AbstractQueryTester {\r\n public static void main(String[] args) throws IOException {\r\n  CodeGenerator.startConnection();\r\n\r\n  CodeGenerator.generateData();\r\n\r\n  EntityManager em = CodeGenerator.getEntityManager();\r\n\r\n  BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n  for (;;) {\r\n   System.out.print(\"Type the NamedQuery name &gt; \");\r\n   String namedQueryName = reader.readLine();\r\n\r\n   if (namedQueryName.equals(\"quit\")) {\r\n    break;\r\n   }\r\n\r\n   if (namedQueryName.length() == 0) {\r\n    continue;\r\n   }\r\n\r\n   System.out.println(\"Type the namedQuery parameters.\");\r\n   System.out.println(\"Press enter for 0 parameters\");\r\n   System.out.println(\"Or type all paramters like: id-2,name-4\");\r\n   String parameters = reader.readLine();\r\n\r\n   try {\r\n    Query query = em.createNamedQuery(namedQueryName);\r\n\r\n    if (parameters.length() &gt; 0) {\r\n     populateParameters(query, parameters);\r\n    }\r\n\r\n    @SuppressWarnings(\"rawtypes\")\r\n    List result = query.getResultList();\r\n\r\n    if (result.size() &gt; 0) {\r\n     int count = 0;\r\n     for (Object o : result) {\r\n      System.out.print(++count + \" \");\r\n      printResult(o);\r\n     }\r\n    } else {\r\n     System.out.println(\"0 results returned\");\r\n    }\r\n   } catch (Exception e) {\r\n    System.err.println(e.getClass() + e.getMessage());\r\n   }\r\n  }\r\n\r\n  CodeGenerator.closeConnection();\r\n }\r\n}<\/pre>\n<p>The code above will start a transaction, create the database data in runtime memory and allow the test of NamedQueries that are configured in the model classes. To test the NamedQueries just type their name in the console.            <\/p>\n<p>To finish the loop do not type any NamedQuery name, just type \u201cquit\u201d and press \u201cEnter\u201d. <\/p>\n<p><strong>Running the application<\/strong>         <\/p>\n<p>Run the class DynamicQueryTester and type the following text in the console: \u201c<i>select p from Person p<\/i>\u201d. Press enter twice and the following text will appear in the console:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-_WcV0L9hSss\/T_QaHUnL1bI\/AAAAAAAAAmM\/KCihSL1ELjI\/s1600\/011.png\"><img decoding=\"async\" border=\"0\" height=\"115\" src=\"http:\/\/2.bp.blogspot.com\/-_WcV0L9hSss\/T_QaHUnL1bI\/AAAAAAAAAmM\/KCihSL1ELjI\/s640\/011.png\" width=\"640\" \/><\/a><\/div>\n<p>At the first \u201cEnter\u201d key hit a message will be displayed asking for parameters if there are any.            <\/p>\n<p>Type in the console: \u201c<i>select p from Person p where p.age &gt; :age<\/i>\u201d and press \u201cEnter\u201d. Type the parameter: \u201c<i>age-69-integer<\/i>\u201d. Press enter and the result bellow will be displayed:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-EtcVvvbkKtU\/T_QaMzGxrNI\/AAAAAAAAAmU\/4GKQCVT1ljY\/s1600\/021.png\"><img decoding=\"async\" border=\"0\" height=\"70\" src=\"http:\/\/2.bp.blogspot.com\/-EtcVvvbkKtU\/T_QaMzGxrNI\/AAAAAAAAAmU\/4GKQCVT1ljY\/s640\/021.png\" width=\"640\" \/><\/a><\/div>\n<p>To finish the code that is running type the word \u201cquit\u201d and press the \u201cEnter\u201d button.            <\/p>\n<p>Run now the code of the class NamedQueryTester.            <\/p>\n<p>Type the NamedQuery name \u201cDog.FindByPerson\u201d in the console and press enter. Type \u201cpersonObject-1-person\u201d parameter and the result bellow will be displayed:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-sB0FDlbj3I0\/T_QaTYz68cI\/AAAAAAAAAmc\/SbiN5Fk-LYA\/s1600\/031.png\"><img decoding=\"async\" border=\"0\" height=\"130\" src=\"http:\/\/1.bp.blogspot.com\/-sB0FDlbj3I0\/T_QaTYz68cI\/AAAAAAAAAmc\/SbiN5Fk-LYA\/s640\/031.png\" width=\"640\" \/><\/a><\/div>\n<p><strong>Using this post code with your application code<\/strong>           <\/p>\n<p>You can use the code of this post in two ways: add your application model class to the project of this post or use the code found in the main package of this project in your application.            <\/p>\n<p><i>Add your model class to the project of this post<\/i>:            <\/p>\n<ul>\n<li>Copy the model class to the \u201ccom.model\u201d package.<\/li>\n<li>Set up the persistence.xml to access the database<\/li>\n<\/ul>\n<p><i>Use the code found in the main package in your application<\/i>:            <\/p>\n<ul>\n<li>Set up the PersistenceUnit found in the CodeGenerator class.<\/li>\n<li>Use the Apache library found in the libs folder: \u201c<i>commons-lang3-3-1.jar<\/i>\u201d.<\/li>\n<\/ul>\n<p>For both approaches the step bellow are required:            <\/p>\n<ul>\n<li>Edit the method \u201c<i>AbstractQueryTester.configureParameterValue<\/i>\u201d to accept all attributes values\/types\/classes that will be used with the queries.<\/li>\n<li>Edit the \u201c<i>hibernate.hbm2ddl.auto<\/i>\u201d configuration to \u201cnone\u201d or \u201cvalidate\u201d. This configuration is found in the \u201c<i>persistence.xml<\/i>\u201d file.<\/li>\n<li>Only invoke the methods to start\/close the connection in the CodeGenerator class.<\/li>\n<\/ul>\n<p><strong>Proposals<\/strong>         <\/p>\n<p>Bellow you will find some proposals to do with this code:            <\/p>\n<ul>\n<li>Use the Reflection technique to create the classes in the \u201c<i>AbstractQueryTester.configureParameterValue<\/i>\u201d method.<\/li>\n<li>Apply Jenkins to validate if some of the JPQLs are with the right syntax after a commit.<\/li>\n<\/ul>\n<p><strong>The End<\/strong>           <\/p>\n<p>I hope this post might help you.            <\/p>\n<p><a href=\"https:\/\/sites.google.com\/site\/uaihebertdeposito\/QueryTester.rar?attredirects=0&amp;d=1\">Click here to download the source code of this post<\/a>.            <\/p>\n<p>If you have any doubt\/suggestion just post it. <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/uaihebert.com\/?p=1476&amp;page=3\">How to test your JPQL \/ HQL without a Deploy <\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Hebert Coelho at the <a href=\"http:\/\/uaihebert.com\/\">uaiHebert<\/a> blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works for any JPA implementation: Hibernate, OpenJPA, EclipseLink and others. The base source code found in this post came from this book: \u201cPro JPA 2: Mastering the &hellip;<\/p>\n","protected":false},"author":154,"featured_media":153,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[589,33,588],"class_list":["post-1580","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-hql","tag-jpa","tag-jpql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Test JPQL \/ HQL without a deploy - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Test JPQL \/ HQL without a deploy - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-05T10:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-22T06:09:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Hebert Coelho\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/uaiHebert\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hebert Coelho\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html\"},\"author\":{\"name\":\"Hebert Coelho\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/997b72fad4d637a8d56a44ea7938ddf5\"},\"headline\":\"Test JPQL \\\/ HQL without a deploy\",\"datePublished\":\"2012-07-05T10:00:00+00:00\",\"dateModified\":\"2012-10-22T06:09:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html\"},\"wordCount\":736,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"keywords\":[\"HQL\",\"JPA\",\"JPQL\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html\",\"name\":\"Test JPQL \\\/ HQL without a deploy - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"datePublished\":\"2012-07-05T10:00:00+00:00\",\"dateModified\":\"2012-10-22T06:09:44+00:00\",\"description\":\"Have you ever wanted to test your JPQL \\\/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/test-jpql-hql-without-deploy.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Test JPQL \\\/ HQL without a deploy\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/997b72fad4d637a8d56a44ea7938ddf5\",\"name\":\"Hebert Coelho\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g\",\"caption\":\"Hebert Coelho\"},\"description\":\"Senior Java Development, with 4 certifications and a published book about JSF (portuguese only). Founder of the blog uaiHebert.com visited from more than 170 different countries.\",\"sameAs\":[\"http:\\\/\\\/uaihebert.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/pub\\\/h%C3%A9bert-coelho-de-oliveira\\\/46\\\/ba8\\\/5bb\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/uaiHebert\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Hebert-Coelho\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Test JPQL \/ HQL without a deploy - Java Code Geeks","description":"Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html","og_locale":"en_US","og_type":"article","og_title":"Test JPQL \/ HQL without a deploy - Java Code Geeks","og_description":"Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works","og_url":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-07-05T10:00:00+00:00","article_modified_time":"2012-10-22T06:09:44+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","type":"image\/jpeg"}],"author":"Hebert Coelho","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/uaiHebert","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Hebert Coelho","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html"},"author":{"name":"Hebert Coelho","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/997b72fad4d637a8d56a44ea7938ddf5"},"headline":"Test JPQL \/ HQL without a deploy","datePublished":"2012-07-05T10:00:00+00:00","dateModified":"2012-10-22T06:09:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html"},"wordCount":736,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","keywords":["HQL","JPA","JPQL"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html","url":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html","name":"Test JPQL \/ HQL without a deploy - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","datePublished":"2012-07-05T10:00:00+00:00","dateModified":"2012-10-22T06:09:44+00:00","description":"Have you ever wanted to test your JPQL \/ HQL without doing a full deploy of your application? What we will see here today is simple solution that works","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/test-jpql-hql-without-deploy.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Test JPQL \/ HQL without a deploy"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/997b72fad4d637a8d56a44ea7938ddf5","name":"Hebert Coelho","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g","caption":"Hebert Coelho"},"description":"Senior Java Development, with 4 certifications and a published book about JSF (portuguese only). Founder of the blog uaiHebert.com visited from more than 170 different countries.","sameAs":["http:\/\/uaihebert.com\/","http:\/\/www.linkedin.com\/pub\/h%C3%A9bert-coelho-de-oliveira\/46\/ba8\/5bb","https:\/\/x.com\/http:\/\/twitter.com\/uaiHebert"],"url":"https:\/\/www.javacodegeeks.com\/author\/Hebert-Coelho"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/154"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1580"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1580\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/153"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}