In my application im using Hibernate 3.3 for the data connection. When im trying to get the resultset by a native query, it throws Cannot cast ‘java.lang.Object[]’ to org.model.Term exception. Model class : Dao method : persistence config : table structure : When query.getSingleResult(); is evaluated the results are there. What might be causing this issue? Answer EntityManager.createNativeQuery(String sqlString) is
Tag: hibernate
How can I implement a Save Or Update function using Spring Data Jpa?
I am using Spring Data JPA to save a record to my database. Here is the method I am using: and my repository: I want to modify this so it will Save or Update. This is what I have so far: I have a few questions – #1 Is this bad practice (deleting and then re-inserting)? #2 If I implement
How to use Redis as L2 cache on Hibernate?
I have a spring boot application and need to setup Redis as l2 cache on hibernate. My prop file looks like: I created a custom region factory because I don’t want to use json or yaml files. (right now, the parameters are hardcoded). CustomRegionFactory class looks like: Using redis-cli I found out that all my entities annotated with @Cacheable are
Why are related entities being escaped when converted to JSON?
I have a Spring MVC controller which fetches some entities via a query. These entities have a related entity that is eagerly fetched. However, when I use JSONObject.toString() it escapes the related model data: The value in the language property is an escaped JSON object from the related entity. Why is it being escaped like that? How do I prevent
ClassNotFoundException for HibernatePersistenceProvider
I have a JSF project which builds perfectly with java 7, but when I try to deploy the WAR in Jboss Application Server, I’m getting the bellow error. The persistance.xml looks like bellow The bellow dependencies are included in the pom The JBoss version is 7.1.1 Final What am I doing wrong here? Answer The issue here was the conflict
EAP 7.3 JPA+Hibernate REST Serialization of Bidirectional ManyToOne relationship (NOT SPRING)
I come from a Payara/EclipseLink background where this just works out of the box. My contract requires me to use EAP which does not support EclipseLink.persistance and I always prefer the “provided” over adding libraries. I am creating a very simple REST microservice with very simple relationships for my objects. However, when I try to access an object, I am
Programmatically restart HikariPool in Spring Boot application?
I have a Spring Boot application which uses Hibernate, and HikariDataSource / HikariPool to talk to the database. A special feature in the app triggers database restart. Currently this breaks the connections in HikariPool: Old version of the app does call programmatically org.hibernate.SessionFactory.close(); which causes restart of HikariDataSource / HikariCP: I would like to do the same, but how can
JPA many to many relationship causing infinite recursion
Edit: I solved the problem using @JsonIgnoreProperties in both classes I have two entities in my api. Pokemon which has a list of “types” that pokemon have and Type which has a list of “pokemon” that have that specific type. I’m trying to implement a getAll method in my controllers but i’m having an infinite recursion problem. I’ve tried to
Bind two Entity without intermediate Entity spring data jpa
I have a user table(and entity) and user groups group users are stored in bind table I want to have in my group entity list of userEntity(without bind entity). Any ideas? Of course, I can use @Query annotation, but I have other entities who mapped with group and they will automatic get group entity. Can I override automatical methods? Answer
Hibernation error many to one. How to create it correctly?
I’m trying to create a many-to-one base, but when adding via .jsp gives an error, via H2 console everything adds ok! Please help me understand how to properly create a many-to-one relationship. It …