sessionfactory

Spring + Hibernate + JPA: How to reload EntityManagerFactory at runtime

戏子无情 提交于 2019-12-07 09:13:49
问题 I have been searching for this the last few hours maybe some of you can help me. I try to achieve a reload of my mapping info in EntityManagerFactory (or SessionFactory) at runtime in spring The EntityManagerFactory is defined as follows: <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceXmlLocation" value="persistence.xml" /> <property name="persistenceUnitName" value="JPAService" /> <property name=

NHibernate SessionFactory Thread safe Issue

随声附和 提交于 2019-12-07 08:14:03
问题 So here is the problem. I have a common class library that holds all the repositories, domain and mapping files so the library can be reused within other web beased applications. Now within this class library there is a peiece of code that allows itself to create a session factory to be used in its repositories. Code looks something like this. private static ISessionFactory sessionFactory; private static Configuration configuration; public static Configuration Configuration() { if

How to make this thread-safe

ぐ巨炮叔叔 提交于 2019-12-07 08:08:29
问题 I have the following SessionFactory for Fluent NHibernate. I am getting an error of An invalid or incomplete configuration was used while creating a SessionFactory. with an InnerException of An item with the same key has already been added. This problem is only happening occasionally and my application works fine most of the time. Based on NHibernate: System.Argument Exception : An item with the same key has already been added I'm guessing my class is not thread-safe which would explain the

Hibernate Sessionfactory restart | Spring

廉价感情. 提交于 2019-12-07 07:37:24
问题 My requirement is as follows: I need to restart(or rebuild) hibernate session factory in my Spring web application at frequent intervals with the new HBM files I get from outside. Currently my Sessionfactory class is as follows with a SessionFactory Proxy to intercept 'OpenSession' call. There I am checking for a condition to restart and rebuilding sessionFactory. My problem here is , in concurrent environment the other users who are in middle of other transaction is getting affected during

SessionFactory injection isn't working

荒凉一梦 提交于 2019-12-07 03:32:29
My SessionFactory isn't being injected to SessionFactory variable. My configuration is as follows: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/beans http://www

Spring + Hibernate with annotations: No Hibernate Session bound to thread

拥有回忆 提交于 2019-12-06 22:34:08
问题 I'm new to Spring and I was trying to create a webapp with the following stack: Apache Tomcat 7, MySQL, Spring MVC, Hibernate 3 with JPA annotations. I am trying to learn by following the book "Spring in Action, Third Edition" by Craig Walls. First, I wanted to create a page that displays some entries I manually added to my DB, but it looks like my application is not capable of creating/retrieving any Hibernate Session from my SessionFactory. Here is my root cause stack trace: exception org

Hibernate opening/closing session, the correct approach for DAO

我与影子孤独终老i 提交于 2019-12-06 07:01:58
问题 I have written this Hibernate object DAO, however with this approach, it is using session per update approach (which I don't think it's right). The reason why I don't think its right because I am running into problems with my User class, which contains collections that are lazily fetched. Since when retrieving each User from the DAO, the session is closed. Therefore I cannot get my collections. From time to time, it is also doing a lot of unnecessary updates to the table because the object is

java.lang.ClassNotFoundException: javax.persistence.NamedStoredProcedureQuery - Hibernate Error

元气小坏坏 提交于 2019-12-05 22:33:24
Above exception has been throwing While creating a hibernate session factory. In application lib folder have hibernate-jpa-2.1-api and javax.persistence.2.1.0. I can able to see the NamedStoredProcedureQuery class in both jar. But I am getting runtime error for classnotfoundexception. Any suggestion? NamedStoredProcedureQuery class is available in hibernate-jpa-2.1-api jar. But this jar refers some other jar in run time. So I didn't get error in compile time and getting exception during runtime. I just added other hibernated libs through maven repository.Initially i used only hibernate-core.

UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0)

我的梦境 提交于 2019-12-05 18:49:40
In the code below when I try to execute Main.java I am getting exception: Exception in thread "main" org.hibernate.UnknownEntityTypeException: Unable to locate persister: com.np.vta.test.pojo.Users at org.hibernate.internal.SessionFactoryImpl.locateEntityPersister(SessionFactoryImpl.java:792) at org.hibernate.internal.SessionImpl.locateEntityPersister(SessionImpl.java:2637) at org.hibernate.internal.SessionImpl.access$2500(SessionImpl.java:164) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2575) at org.hibernate.internal.SessionImpl

Hibernate Sessionfactory restart | Spring

瘦欲@ 提交于 2019-12-05 16:05:13
My requirement is as follows: I need to restart(or rebuild) hibernate session factory in my Spring web application at frequent intervals with the new HBM files I get from outside. Currently my Sessionfactory class is as follows with a SessionFactory Proxy to intercept 'OpenSession' call. There I am checking for a condition to restart and rebuilding sessionFactory. My problem here is , in concurrent environment the other users who are in middle of other transaction is getting affected during this restart. Is there anyway to carryout the restart by checking all the transactions and open sessions