Hibernate's core Object/Relational Mapping functionality (prefer the hibernate-user room/stream on https://hibernate.zulipchat.com)
Hello there,
not sure if it is the right place to ask, but we found a serious issue with logging of an Exception:
HHH000315: Exception executing batch [java.sql.BatchUpdateException: Batch entry 0 insert into table (colum1, column2, columnn) values ('paylpad1', 'payload2', PERSONAL_INFORMATION) was aborted: An I/O error occurred while sending to the backend. Call getNextException to see other errors in the batch.], SQL: insert into table (colum1, column2, columnn) values (?, ?, ?)",
This is reported to our logging stack and would be stored for a long period of time. But we are not allowed to store personalInformation in that storage for that time.
So we guessed that, there could be an option to mask columns in Exceptions due sensible information. But we did not found something related to that. The way around would be to change the Logback ConsoleAppender. But is there something alread inside Hibernate to do that?
Dear @sebersole @DavideD
I am using reactive hibernate (1.0.0.CR7) for my spring webflux project. I am getting the object array data while executing native queries and it is working fine. But I need it as a tuple object. So I passed Tuple.class argument to createNativeQuery method. But it will throw an exception as it cannot cast an object to tuple. I just need the data with column names. So I choose tuple instead of object array. Kindly help.
Sample code:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("Persistence");
Mutiny.SessionFactory sessionFactory = emf.unwrap(Mutiny.SessionFactory.class);
Mutiny.Session session = sessionFactory.openSession();
String str = "select c.country_name as country_name, c.phone_code as phone_code
from erp_country c"; // MySql query
Mutiny.Query<Tuple> query = session.createNativeQuery(str, Tuple.class);
List<Tuple> list = query.getResultList().await().indefinitely();
for (Tuple tuple : list) { // here it will throw an exception as object cannot be cast to class javax.persistence.Tuple
System.out.println(tuple.get("country_name") + "-" + tuple.get("phone_code"));
}
Exception Message:
Ljava.lang.Object; cannot be cast to class javax.persistence.Tuple ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; javax.persistence.Tuple is in unnamed module of loader 'app')
List<Object[]> results = session.createNativeQuery(str).getResultList().await().indefinitely();
for (Object[] tuple : results ) {
String countryName = tuple[0];
Object countryCode = tuple[1];
}
@DavideD
thank you for your response.
I have another project using JPA- hibernate 5.5. There I can pass the second parameter of createNativeQuery as tuple class instead of giving an entity class. So I thought may be there is a chance to use Tuple in reactive hibernate also. If we use tuple class then we can retrieve the data by using alias name in the query string.
Few reference:
https://stackoverflow.com/questions/44626609/getting-column-names-from-a-jpa-native-query
https://stackoverflow.com/questions/16296853/jpa-result-list-cast-object-to-tuple
Anyway, I will go with object array as you have mentioned.
HibernateTransactionManager
is a Spring class, not a Hibernate class. Not sure why people routinely come ask us about issues using Hibernate via Spring
ClassNotFoundException: javax.xml.bind.JAXBException
. Considering that Hibernate 5.5. supports Jakarta, I would have thought, that it's looking for jakarta.xml.bind.JAXBException
. Not javax. What's going on here?
javax
is still the primary target for versions inclusing 5.6; we switched to jakarta
primarily starting in 6.0. So for 5.5, you'd need to be sure to use the jakarta variant (hibernate-core-jakarta
e.g.)