open-session-in-view

Open Session in View vs @Transactional

冷暖自知 提交于 2020-03-22 06:56:12
问题 I had been using @Transactional annotations in my Service Layer. But to resolve an error due to Lazy Loading in View I had to use Open Session in View Filter . After this, without use of @Transaction itself a Session gets opened and transaction starts. So does that mean @Transactions are not required? How will transactions and roll-backs be handled, then in Service Layers? 回答1: The javadoc explains it: This filter makes Hibernate Sessions available via the current thread, which will be

Spring.NET + NHibernate - Multiple (Distinct) Databases with OpenSessionInView

て烟熏妆下的殇ゞ 提交于 2020-01-17 03:45:08
问题 In my web application, I have 2 totally different databases - one that's being used mostly by a CMS from which we'd like to get page information on non CMS pages on the same website, & one that contains totally different data. Is it possible to use Spring.NET's Open Session In View module with multiple session factories for both of those databases, so in this case I have 2 objects defined in spring.config of type Spring.Data.NHibernate.LocalSessionFactoryObject ? 回答1: I think you are talking

Spring, Hibernate, Tiles, OpenSessionInViewFilter and LazyInitializationException

大憨熊 提交于 2019-12-13 00:56:32
问题 I received LazyInitializationException on jsp when tried to get access to colection which was lazy loaded: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.navigator.category.alias.CategoryAlias.products, no session or session was closed org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383) org.hibernate.collection.AbstractPersistentCollection

JPA @Entity not managed after creation?

旧城冷巷雨未停 提交于 2019-12-11 14:16:40
问题 I have a simple controller method, where I create a new object Car and then set its name to Audi : @GetMapping(value = "/resource") public ResponseEntity visit() { Car car = carRepo.save(new Car("VolksWagen")); // Car should be managed now? car.setName("Audi"); // <-- has no effect on database state return ResponseEntity.ok().build(); } In the database, it never becomes an Audi , but stays a VolksWagen . Why does this happen? Shouldn't the newly created Car be in managed state for the

Hibernate Update Problems - OpenSessionInViewFilter

♀尐吖头ヾ 提交于 2019-12-08 08:57:17
问题 It's been about 5 hours trying to update an object through hibernate in my application using Spring MVC 3 and OpenSessionInViewFilter without any luck. I've possibly gone through all the threads available in StackOverflow and other forums! Hibernate doesn't throw any error, and says the object was updated but it doesn't reflect in my DB. Any help would be massively appreciated. So, here's my JSON request to update: { "id": "14", "name": "Whatever", "contactNumber": "918026754027", "manager":

LazyInitializationException in spite of OpenSessionInViewFilter

倖福魔咒の 提交于 2019-12-04 14:07:01
问题 I seem to be randomly getting the following LazyInitializationException in a Spring/MVC 3.0/Hibernate 3.5 application in spite of seeing the filter in the stack trace itself. Any idea on what I should look into? 07 Jun 2011 13:48:47,152 [ERROR] (http-3443-2) org.hibernate.LazyInitializationException: could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize

LazyInitializationException in spite of OpenSessionInViewFilter

只愿长相守 提交于 2019-12-03 09:42:27
I seem to be randomly getting the following LazyInitializationException in a Spring/MVC 3.0/Hibernate 3.5 application in spite of seeing the filter in the stack trace itself. Any idea on what I should look into? 07 Jun 2011 13:48:47,152 [ERROR] (http-3443-2) org.hibernate.LazyInitializationException: could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation

Configuring OpenSessionInViewFilter with Spring 3 and Servlet 3

我的梦境 提交于 2019-12-03 09:16:47
问题 i want to configure OpenSessionInViewFilter to able to use hibernate lazy initialization in view, so i added the filter definition in web.xml, but it doesn't work i still get the same lazy initialization exception, here's what i did: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

Getting No bean named 'sessionFactory' error when using OpenSessionInViewFilter

冷暖自知 提交于 2019-12-01 06:36:14
问题 I am using Hibernate's lazy loading, and after adding OpenSessionInViewFilter to my web.xml I started to get sessionFactory missing exception, even after defining the sessionFactory bean to use. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529) org.springframework.beans.factory.support.AbstractBeanFactory

Hibernate Open Session in View: Transaction per Request?

筅森魡賤 提交于 2019-11-29 23:19:47
I'm using Hibernate with Spring on Tomcat. I've been reading and re-reading the oft pointed to JBoss wiki page on the topic, and that has been helpful. But it leaves me with some questions. The idea of starting a transaction for every request troubles me. I guess I could limit the filter to certain controllers -- maybe put all my controllers that need a transaction under a pseudo "tx" path or something. But isn't it a bad idea to use transactions if you don't know if you're going to need one? And if I'm just doing reads in some request -- reads that very likely may come from a cache -- aren't