⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ public class SearchRepository {
DataSource dataSource;

public List<Product> searchProduct (String input) {
return null;
// lowercase the input
var lowerInput = input.toLowerCase(Locale.ROOT);

// create a query using named parameters that matches the lowerinput to the product description or product name
var query = em.createQuery("Select p from Product p where lower(p.description) like :input OR lower(p.productName) like :input", Product.class);

// set the input parameter
query.setParameter("input", "%" + lowerInput + "%");

// get the result list
var resultList = (List<Product>) query.getResultList();
return resultList;
}

}
5 changes: 5 additions & 0 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
</head>
<body>
<div class="container">
<!-- add a header fragment -->
<!--/*/ <th:block th:include="fragments/header :: header"></th:block> /*/-->
<!-- add a productsTable fragment -->
<!--/*/ <th:block th:include="fragments/productsTable :: productsTable"></th:block> /*/-->


</div>
</body>
Expand Down