I have this method : Mapping : Person.hbm.xml Cars.hbm.xml This method works well for a single thread, and on multiple threads, gives me an error: AOP Transaction : NB : When i add Thread.sleep(5000) after update, it is ok. But this solution is not clean. Answer I have Cars -> (1 -n) places. And i have a foreign key in
Tag: hibernate
JPA PessimisticLockScope.NORMAL and locking “relationships”
I am studying JPA Documentation and encountered the following lines: Entity relationships for which the locked entity contains the foreign key will also be locked, but not the state of the referenced entities (unless those entities are explicitly locked). Element collections and relationships for which the entity does not contain the foreign key (such as relationships that are mapped to
High memory usage when using Hibernate
I code a server side application with java run on linux server. I use hibernate to open session to database, use native sql to query it and always close this session by try, catch, finally. My server query DB using hibernate with very high frequency. I already define MaxHeapSize for it is 3000M but it usually use 2.7GB on RAM,
JPA @Version field doesn’t get incremented
I’m new to JPA and Hibernate and I have a problem with optimistic locking. I have a class which has an @Version annotated field. When I update the Entity represented by this class, the version counter does not increase. Here is my code: The class: and here is the main method: and here is what the console says: Can somebody
Spring @Transactional on one service method spanning over two Hibernate transaction managers
I was wondering if it is possible to use two transaction manager in one service methods. Because due to the limitation of client’s mysql db configuration, we have got 2 different datasources within one database, i.e., one user/pwd/url per schema. Thats why i have to configured two transaction managers. Now I got problem when it comes to the service implementation.
First level cache not working with JPA and Hibernate
I an new to use hibernate caching (first level, 2nd level and query cache). My project is configured using Spring MVC and JPA. I am testing first level cache using JUnit test case below. And my entity class is defined as : This should execute native query once in case first level cache is by default enabled. But I am
Why is there a class with entity name plus an underscore for JPA entity class
I am new to JPA, I have created a class like the following I noted that there is another class with name as my entity java class Programme.java with an underscore i.e. Programme_.java. What is this class and why is this generated. Is there any way that I can stop its generation? the code for the Programme_.java class is as
How to fix Hibernate LazyInitializationException: failed to lazily initialize a collection of roles, could not initialize proxy – no Session
In the custom AuthenticationProvider from my spring project, I am trying read the list of authorities of the logged user, but I am facing the following error: Reading other topics from here in StackOverflow, I understand this happens due the way this type of atribute is handled by the framework, but i can’t figure out any solution for my case.
Hibernate C3P0 settings performance issues
Since we have added C3P0 connection pooling to the application performance became slower. It is Oracle 10g database, Hibernate 3.1.3 and C3P0 0.9.0.4. WebSphere application server. I am very new to this things, so I don’t understand everything. Is this configuration could slow down the app performance? What should I change if so? Answer c3p0-0.9.0.x is very, very old. Please
Failed to start service jboss.persistenceunit: org.hibernate.service.UnknownServiceException
I would like to ask if somebody could help to resolve this problem because I’m stuck with it and I don’t know where the problem could be. Until now I developed my application under Glassfish Server 4. Now I deceided to change my server for WildFly and I edited some configs to be able to run it on Wild Fly.