minor cleanup work

This commit is contained in:
eugenp 2017-03-11 21:53:39 +02:00
parent ffb24cf312
commit 86eb549596
12 changed files with 37 additions and 75 deletions

View File

@ -28,10 +28,6 @@ import com.baeldung.hibernate.criteria.util.HibernateUtil;
public class ApplicationView { public class ApplicationView {
public ApplicationView() {
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean checkIfCriteriaTimeLower() { public boolean checkIfCriteriaTimeLower() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
@ -181,8 +177,7 @@ public class ApplicationView {
CriteriaBuilder builder = session.getCriteriaBuilder(); CriteriaBuilder builder = session.getCriteriaBuilder();
CriteriaQuery<Item> criteriaItem = builder.createQuery(Item.class); CriteriaQuery<Item> criteriaItem = builder.createQuery(Item.class);
Root<Item> rootItem = criteriaItem.from(Item.class); Root<Item> rootItem = criteriaItem.from(Item.class);
criteriaItem.select(rootItem).where(builder.isNull(rootItem.get("itemDescription"))) criteriaItem.select(rootItem).where(builder.isNull(rootItem.get("itemDescription"))).where(builder.like(rootItem.get("itemName"), "chair%"));
.where(builder.like(rootItem.get("itemName"), "chair%"));
final List<Item> notNullItemsList = session.createQuery(criteriaItem).getResultList(); final List<Item> notNullItemsList = session.createQuery(criteriaItem).getResultList();
final String notNullDescItems[] = new String[notNullItemsList.size()]; final String notNullDescItems[] = new String[notNullItemsList.size()];
for (int i = 0; i < notNullItemsList.size(); i++) { for (int i = 0; i < notNullItemsList.size(); i++) {

View File

@ -47,7 +47,7 @@ public class Event {
this.title = title; this.title = title;
} }
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE}) @Cascade({ CascadeType.SAVE_UPDATE, CascadeType.DELETE })
public Set<String> getGuestList() { public Set<String> getGuestList() {
return guestList; return guestList;
} }

View File

@ -15,9 +15,7 @@ public class HibernateUtil {
Configuration configuration = new Configuration(); Configuration configuration = new Configuration();
configuration.addAnnotatedClass(Event.class); configuration.addAnnotatedClass(Event.class);
configuration.configure("immutable.cfg.xml"); configuration.configure("immutable.cfg.xml");
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
.applySettings(configuration.getProperties())
.build();
return configuration.buildSessionFactory(serviceRegistry); return configuration.buildSessionFactory(serviceRegistry);
} catch (Throwable ex) { } catch (Throwable ex) {
System.out.println("Initial SessionFactory creation failed." + ex); System.out.println("Initial SessionFactory creation failed." + ex);

View File

@ -8,8 +8,7 @@ import com.baeldung.persistence.dao.common.IOperations;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Transactional(value = "hibernateTransactionManager") @Transactional(value = "hibernateTransactionManager")
public abstract class AbstractHibernateAuditableService<T extends Serializable> extends AbstractHibernateService<T> public abstract class AbstractHibernateAuditableService<T extends Serializable> extends AbstractHibernateService<T> implements IOperations<T>, IAuditOperations<T> {
implements IOperations<T>, IAuditOperations<T> {
@Override @Override
public List<T> getEntitiesAtRevision(final Number revision) { public List<T> getEntitiesAtRevision(final Number revision) {

View File

@ -7,8 +7,7 @@ import com.baeldung.persistence.dao.common.IOperations;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Transactional(value = "hibernateTransactionManager") @Transactional(value = "hibernateTransactionManager")
public abstract class AbstractHibernateService<T extends Serializable> extends AbstractService<T> implements public abstract class AbstractHibernateService<T extends Serializable> extends AbstractService<T> implements IOperations<T> {
IOperations<T> {
@Override @Override
public T findOne(final long id) { public T findOne(final long id) {

View File

@ -24,8 +24,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testLikeCriteriaQuery() { public void testLikeCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedLikeList = session.createQuery("From Item where itemName like '%chair%'") final List<Item> expectedLikeList = session.createQuery("From Item where itemName like '%chair%'").getResultList();
.getResultList();
final String expectedLikeItems[] = new String[expectedLikeList.size()]; final String expectedLikeItems[] = new String[expectedLikeList.size()];
for (int i = 0; i < expectedLikeList.size(); i++) { for (int i = 0; i < expectedLikeList.size(); i++) {
expectedLikeItems[i] = expectedLikeList.get(i).getItemName(); expectedLikeItems[i] = expectedLikeList.get(i).getItemName();
@ -37,8 +36,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testILikeCriteriaQuery() { public void testILikeCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedChairCaseList = session.createQuery("From Item where itemName like '%Chair%'") final List<Item> expectedChairCaseList = session.createQuery("From Item where itemName like '%Chair%'").getResultList();
.getResultList();
final String expectedChairCaseItems[] = new String[expectedChairCaseList.size()]; final String expectedChairCaseItems[] = new String[expectedChairCaseList.size()];
for (int i = 0; i < expectedChairCaseList.size(); i++) { for (int i = 0; i < expectedChairCaseList.size(); i++) {
expectedChairCaseItems[i] = expectedChairCaseList.get(i).getItemName(); expectedChairCaseItems[i] = expectedChairCaseList.get(i).getItemName();
@ -51,8 +49,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testNullCriteriaQuery() { public void testNullCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedIsNullDescItemsList = session.createQuery("From Item where itemDescription is null") final List<Item> expectedIsNullDescItemsList = session.createQuery("From Item where itemDescription is null").getResultList();
.getResultList();
final String expectedIsNullDescItems[] = new String[expectedIsNullDescItemsList.size()]; final String expectedIsNullDescItems[] = new String[expectedIsNullDescItemsList.size()];
for (int i = 0; i < expectedIsNullDescItemsList.size(); i++) { for (int i = 0; i < expectedIsNullDescItemsList.size(); i++) {
expectedIsNullDescItems[i] = expectedIsNullDescItemsList.get(i).getItemName(); expectedIsNullDescItems[i] = expectedIsNullDescItemsList.get(i).getItemName();
@ -64,8 +61,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testIsNotNullCriteriaQuery() { public void testIsNotNullCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedIsNotNullDescItemsList = session.createQuery( final List<Item> expectedIsNotNullDescItemsList = session.createQuery("From Item where itemDescription is not null").getResultList();
"From Item where itemDescription is not null").getResultList();
final String expectedIsNotNullDescItems[] = new String[expectedIsNotNullDescItemsList.size()]; final String expectedIsNotNullDescItems[] = new String[expectedIsNotNullDescItemsList.size()];
for (int i = 0; i < expectedIsNotNullDescItemsList.size(); i++) { for (int i = 0; i < expectedIsNotNullDescItemsList.size(); i++) {
expectedIsNotNullDescItems[i] = expectedIsNotNullDescItemsList.get(i).getItemName(); expectedIsNotNullDescItems[i] = expectedIsNotNullDescItemsList.get(i).getItemName();
@ -78,8 +74,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testAverageProjection() { public void testAverageProjection() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Double> expectedAvgProjItemsList = session.createQuery("Select avg(itemPrice) from Item item") final List<Double> expectedAvgProjItemsList = session.createQuery("Select avg(itemPrice) from Item item").getResultList();
.getResultList();
final Double expectedAvgProjItems[] = new Double[expectedAvgProjItemsList.size()]; final Double expectedAvgProjItems[] = new Double[expectedAvgProjItemsList.size()];
for (int i = 0; i < expectedAvgProjItemsList.size(); i++) { for (int i = 0; i < expectedAvgProjItemsList.size(); i++) {
@ -105,8 +100,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testOrCriteriaQuery() { public void testOrCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedOrCritItemsList = session.createQuery( final List<Item> expectedOrCritItemsList = session.createQuery("From Item where itemPrice>1000 or itemName like 'Chair%'").getResultList();
"From Item where itemPrice>1000 or itemName like 'Chair%'").getResultList();
final String expectedOrCritItems[] = new String[expectedOrCritItemsList.size()]; final String expectedOrCritItems[] = new String[expectedOrCritItemsList.size()];
for (int i = 0; i < expectedOrCritItemsList.size(); i++) { for (int i = 0; i < expectedOrCritItemsList.size(); i++) {
expectedOrCritItems[i] = expectedOrCritItemsList.get(i).getItemName(); expectedOrCritItems[i] = expectedOrCritItemsList.get(i).getItemName();
@ -118,8 +112,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testAndCriteriaQuery() { public void testAndCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedAndCritItemsList = session.createQuery( final List<Item> expectedAndCritItemsList = session.createQuery("From Item where itemPrice>1000 and itemName like 'Chair%'").getResultList();
"From Item where itemPrice>1000 and itemName like 'Chair%'").getResultList();
final String expectedAndCritItems[] = new String[expectedAndCritItemsList.size()]; final String expectedAndCritItems[] = new String[expectedAndCritItemsList.size()];
for (int i = 0; i < expectedAndCritItemsList.size(); i++) { for (int i = 0; i < expectedAndCritItemsList.size(); i++) {
expectedAndCritItems[i] = expectedAndCritItemsList.get(i).getItemName(); expectedAndCritItems[i] = expectedAndCritItemsList.get(i).getItemName();
@ -131,8 +124,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testMultiCriteriaQuery() { public void testMultiCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedMultiCritItemsList = session.createQuery( final List<Item> expectedMultiCritItemsList = session.createQuery("From Item where itemDescription is null and itemName like'chair%'").getResultList();
"From Item where itemDescription is null and itemName like'chair%'").getResultList();
final String expectedMultiCritItems[] = new String[expectedMultiCritItemsList.size()]; final String expectedMultiCritItems[] = new String[expectedMultiCritItemsList.size()];
for (int i = 0; i < expectedMultiCritItemsList.size(); i++) { for (int i = 0; i < expectedMultiCritItemsList.size(); i++) {
expectedMultiCritItems[i] = expectedMultiCritItemsList.get(i).getItemName(); expectedMultiCritItems[i] = expectedMultiCritItemsList.get(i).getItemName();
@ -144,8 +136,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testSortCriteriaQuery() { public void testSortCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedSortCritItemsList = session.createQuery( final List<Item> expectedSortCritItemsList = session.createQuery("From Item order by itemName asc, itemPrice desc").getResultList();
"From Item order by itemName asc, itemPrice desc").getResultList();
final String expectedSortCritItems[] = new String[expectedSortCritItemsList.size()]; final String expectedSortCritItems[] = new String[expectedSortCritItemsList.size()];
for (int i = 0; i < expectedSortCritItemsList.size(); i++) { for (int i = 0; i < expectedSortCritItemsList.size(); i++) {
expectedSortCritItems[i] = expectedSortCritItemsList.get(i).getItemName(); expectedSortCritItems[i] = expectedSortCritItemsList.get(i).getItemName();
@ -157,8 +148,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void testGreaterThanCriteriaQuery() { public void testGreaterThanCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedGreaterThanList = session.createQuery("From Item where itemPrice>1000") final List<Item> expectedGreaterThanList = session.createQuery("From Item where itemPrice>1000").getResultList();
.getResultList();
final String expectedGreaterThanItems[] = new String[expectedGreaterThanList.size()]; final String expectedGreaterThanItems[] = new String[expectedGreaterThanList.size()];
for (int i = 0; i < expectedGreaterThanList.size(); i++) { for (int i = 0; i < expectedGreaterThanList.size(); i++) {
expectedGreaterThanItems[i] = expectedGreaterThanList.get(i).getItemName(); expectedGreaterThanItems[i] = expectedGreaterThanList.get(i).getItemName();
@ -182,8 +172,7 @@ public class HibernateCriteriaIntegrationTest {
@Test @Test
public void betweenCriteriaQuery() { public void betweenCriteriaQuery() {
final Session session = HibernateUtil.getHibernateSession(); final Session session = HibernateUtil.getHibernateSession();
final List<Item> expectedBetweenList = session.createQuery("From Item where itemPrice between 100 and 200") final List<Item> expectedBetweenList = session.createQuery("From Item where itemPrice between 100 and 200").getResultList();
.getResultList();
final String expectedPriceBetweenItems[] = new String[expectedBetweenList.size()]; final String expectedPriceBetweenItems[] = new String[expectedBetweenList.size()];
for (int i = 0; i < expectedBetweenList.size(); i++) { for (int i = 0; i < expectedBetweenList.size(); i++) {
expectedPriceBetweenItems[i] = expectedBetweenList.get(i).getItemName(); expectedPriceBetweenItems[i] = expectedBetweenList.get(i).getItemName();

View File

@ -9,7 +9,7 @@ public class HibernateCriteriaTestRunner {
public static void main(final String[] args) { public static void main(final String[] args) {
Result result = JUnitCore.runClasses(HibernateCriteriaTestSuite.class); Result result = JUnitCore.runClasses(HibernateCriteriaTestSuite.class);
for (Failure failure : result.getFailures()) { for (Failure failure : result.getFailures()) {
//
} }
} }
} }

View File

@ -45,8 +45,7 @@ public class HibernateImmutableIntegrationTest {
@Test @Test
public void updateEvent() { public void updateEvent() {
Event event = (Event) session.createQuery( Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0);
"FROM Event WHERE title='New Event'").list().get(0);
event.setTitle("Private Event"); event.setTitle("Private Event");
session.saveOrUpdate(event); session.saveOrUpdate(event);
session.getTransaction().commit(); session.getTransaction().commit();
@ -54,16 +53,14 @@ public class HibernateImmutableIntegrationTest {
@Test @Test
public void deleteEvent() { public void deleteEvent() {
Event event = (Event) session.createQuery( Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0);
"FROM Event WHERE title='New Event'").list().get(0);
session.delete(event); session.delete(event);
session.getTransaction().commit(); session.getTransaction().commit();
} }
@Test @Test
public void addGuest() { public void addGuest() {
Event event = (Event) session.createQuery( Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0);
"FROM Event WHERE title='New Event'").list().get(0);
String newGuest = "Sara"; String newGuest = "Sara";
event.getGuestList().add(newGuest); event.getGuestList().add(newGuest);
@ -74,8 +71,7 @@ public class HibernateImmutableIntegrationTest {
@Test @Test
public void deleteCascade() { public void deleteCascade() {
Event event = (Event) session.createQuery( Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0);
"FROM Event WHERE title='New Event'").list().get(0);
String guest = event.getGuestList().iterator().next(); String guest = event.getGuestList().iterator().next();
event.getGuestList().remove(guest); event.getGuestList().remove(guest);

View File

@ -73,8 +73,7 @@ public class FooPaginationPersistenceIntegrationTest {
public final void whenRetrievingPaginatedEntities_thenCorrectSize() { public final void whenRetrievingPaginatedEntities_thenCorrectSize() {
final int pageNumber = 1; final int pageNumber = 1;
final int pageSize = 10; final int pageSize = 10;
final List<Foo> fooList = session.createQuery("From Foo").setFirstResult((pageNumber - 1) * pageSize) final List<Foo> fooList = session.createQuery("From Foo").setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).getResultList();
.setMaxResults(pageSize).getResultList();
assertThat(fooList, hasSize(pageSize)); assertThat(fooList, hasSize(pageSize));
} }
@ -90,8 +89,7 @@ public class FooPaginationPersistenceIntegrationTest {
final List<Foo> fooList = Lists.newArrayList(); final List<Foo> fooList = Lists.newArrayList();
int totalEntities = 0; int totalEntities = 0;
while (totalEntities < countResult) { while (totalEntities < countResult) {
fooList.addAll(session.createQuery("From Foo").setFirstResult((pageNumber - 1) * pageSize) fooList.addAll(session.createQuery("From Foo").setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).getResultList());
.setMaxResults(pageSize).getResultList());
totalEntities = fooList.size(); totalEntities = fooList.size();
pageNumber++; pageNumber++;
} }
@ -106,8 +104,7 @@ public class FooPaginationPersistenceIntegrationTest {
final Long countResults = (Long) session.createQuery(countQ).uniqueResult(); final Long countResults = (Long) session.createQuery(countQ).uniqueResult();
final int lastPageNumber = (int) ((countResults / pageSize) + 1); final int lastPageNumber = (int) ((countResults / pageSize) + 1);
final List<Foo> lastPage = session.createQuery("From Foo").setFirstResult((lastPageNumber - 1) * pageSize) final List<Foo> lastPage = session.createQuery("From Foo").setFirstResult((lastPageNumber - 1) * pageSize).setMaxResults(pageSize).getResultList();
.setMaxResults(pageSize).getResultList();
assertThat(lastPage, hasSize(lessThan(pageSize + 1))); assertThat(lastPage, hasSize(lessThan(pageSize + 1)));
} }
@ -147,8 +144,7 @@ public class FooPaginationPersistenceIntegrationTest {
CriteriaQuery<Foo> criteriaItem = builder.createQuery(Foo.class); CriteriaQuery<Foo> criteriaItem = builder.createQuery(Foo.class);
Root<Foo> rootItem = criteriaItem.from(Foo.class); Root<Foo> rootItem = criteriaItem.from(Foo.class);
criteriaItem.select(rootItem); criteriaItem.select(rootItem);
final List<Foo> firstPage = session.createQuery(criteriaItem).setFirstResult(0).setMaxResults(pageSize) final List<Foo> firstPage = session.createQuery(criteriaItem).setFirstResult(0).setMaxResults(pageSize).getResultList();
.getResultList();
assertThat(firstPage, hasSize(pageSize)); assertThat(firstPage, hasSize(pageSize));
} }
@ -175,8 +171,7 @@ public class FooPaginationPersistenceIntegrationTest {
int totalEntities = 0; int totalEntities = 0;
while (totalEntities < count.intValue()) { while (totalEntities < count.intValue()) {
fooList.addAll(session.createQuery(criteriaFoo).setFirstResult((pageNumber - 1) * pageSize) fooList.addAll(session.createQuery(criteriaFoo).setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).getResultList());
.setMaxResults(pageSize).getResultList());
totalEntities = fooList.size(); totalEntities = fooList.size();
pageNumber++; pageNumber++;
} }

View File

@ -11,8 +11,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order; import javax.persistence.criteria.Order;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import org.hibernate.Criteria;
import org.hibernate.NullPrecedence;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.junit.After; import org.junit.After;

View File

@ -37,14 +37,9 @@ public class SaveMethodsTest {
@BeforeClass @BeforeClass
public static void beforeTests() { public static void beforeTests() {
Configuration configuration = new Configuration().addAnnotatedClass(Person.class) Configuration configuration = new Configuration().addAnnotatedClass(Person.class).setProperty("hibernate.dialect", HSQLDialect.class.getName()).setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
.setProperty("hibernate.dialect", HSQLDialect.class.getName()) .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test").setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "").setProperty("hibernate.hbm2ddl.auto", "update");
.setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName()) ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test")
.setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "")
.setProperty("hibernate.hbm2ddl.auto", "update");
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry); sessionFactory = configuration.buildSessionFactory(serviceRegistry);
} }
@ -269,10 +264,10 @@ public class SaveMethodsTest {
@After @After
public void tearDown() { public void tearDown() {
try{ try {
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
}catch(TransactionException ex){ } catch (TransactionException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }

View File

@ -96,16 +96,14 @@ public class FooStoredProceduresIntegrationTest {
fooService.create(new Foo("NewFooName")); fooService.create(new Foo("NewFooName"));
// Stored procedure getFoosByName using createSQLQuery() // Stored procedure getFoosByName using createSQLQuery()
List<Foo> allFoosByName = session.createQuery("CALL GetFoosByName(:fooName)", Foo.class) List<Foo> allFoosByName = session.createQuery("CALL GetFoosByName(:fooName)", Foo.class).setParameter("fooName", "NewFooName").getResultList();
.setParameter("fooName", "NewFooName").getResultList();
for (Foo foo : allFoosByName) { for (Foo foo : allFoosByName) {
LOGGER.info("getFoosByName() using SQL Query : found => {}", foo.toString()); LOGGER.info("getFoosByName() using SQL Query : found => {}", foo.toString());
} }
// Stored procedure getFoosByName using getNamedQuery() // Stored procedure getFoosByName using getNamedQuery()
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Foo> allFoosByName2 = session.getNamedQuery("callGetFoosByName").setParameter("fooName", "NewFooName") List<Foo> allFoosByName2 = session.getNamedQuery("callGetFoosByName").setParameter("fooName", "NewFooName").getResultList();
.getResultList();
for (Foo foo : allFoosByName2) { for (Foo foo : allFoosByName2) {
LOGGER.info("getFoosByName() using Native Query : found => {}", foo.toString()); LOGGER.info("getFoosByName() using Native Query : found => {}", foo.toString());
} }