static EntityManager entityManager = Persistence
.createEntityManagerFactory("JPA").createEntityManager();
TypedQuery<Syntax> qs = entityManager.createQuery(
"select synatx from Syntax synatx "
+ "where synatx.java = ?1", Syntax.class);
qs.setParameter(1, "public class");
List<Syntax> syntax = qs.getResultList();
if (syntax != null) {
for (Syntax syntaxList : syntax) {
System.out.println("-dynamic-" + syntaxlist.getdynamicsyntax);
}
}
StringBuilder where = new StringBuilder();
where.append("person.firstName=:firstName");
TypedQuery<Person> qss = entityManager
.createQuery("select person from Person person where " + where,
Person.class);
qss.setParameter("firstName", "abis");
List<Person> personss = qss.getResultList();
if (personss != null) {
for (Person personList : personss) {
System.out.println("-Last Name-" + personList.getLastName());
}
}
No comments:
Post a Comment