So I have set up hibernate with Wildfly and MySql.
Querying works, but have problem querying UTF-8 character names.
On MySql:
SELECT * FROM users WHERE firstname = "ნიკა";
Doesn't result in empty set.
While in java:
Session session = HibernateUtils.getSession();
String name = request.getParameter("name");
CriteriaBuilder builder = session.getCriteriaBuilder();
CriteriaQuery<UsersEntity> query = builder.createQuery(UsersEntity.class);
Root<UsersEntity> usersRoot = query.from(UsersEntity.class);
query.select(usersRoot)
.where(builder.equal(usersRoot.get("firstname"), name));
List<UsersEntity> list = session.createQuery(query).list();
session.close();
writeUsers(list, response.getWriter());
Results in an empty set when querying localhost:8080/main?name=ნიკა
How do I fix this ?
UPDATE:
I also have issue that when querying all data and displaying them non english characters are replaced with question marks.
UPDATE 2:
This code results in showing up question marks on browser:
response.getWriter().write("ნიკა ჩხარტიშვილი");
While this one works properly:
response.setCharacterEncoding("UTF-8");
response.getWriter().write("ნიკა ჩხარტიშვილი");
When querying database with this query SELECT * FROM users WHERE username='ნიკა'
database receives question marks instead of ნიკა
(That's what shows up in wireshark).
I think it's wildfly issue because it received UTF-8 correctly but sends question marks unless it's specified to send UTF-8.