transactional

org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode

不打扰是莪最后的温柔 提交于 2019-11-29 16:06:22
I am using Spring , JPA, Hibernate, Postgresql. I can upload/insert a file to the database. But I got the error when tried to access the file. EVERE: Servlet.service() for servlet default threw exception org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode. at org.postgresql.largeobject.LargeObjectManager.open(LargeObjectManager.java:200) at org.postgresql.largeobject.LargeObjectManager.open(LargeObjectManager.java:172) at org.postgresql.jdbc2.AbstractJdbc2BlobClob.<init>(AbstractJdbc2BlobClob.java:47) at org.postgresql.jdbc2.AbstractJdbc2Blob.<init>

LazyInitializationException Within a @Transactional Method

隐身守侯 提交于 2019-11-29 10:39:54
I am running into the org.hibernate.LazyInitializationException error when I try to access a lazy loaded exception when excecuting the following: @Transactional public void displayAddresses() { Person person = getPersonByID(1234); List<Address> addresses = person.getAddresses(); // Exception Thrown Here for(Address address : addresses) System.out.println(address.getFullAddress()); } My entities look like this: @Entity @Table("PERSON_TBL") public class Person { ... @OneToMany(cascade=CascadeType.ALL, targetEntity=Address.class, mappedBy="person") private List<Address> addresses; ... } @Entity

Hibernate SQLQuery bypasses hibernate session cache

邮差的信 提交于 2019-11-29 07:47:19
I'm "transactionalizing" some extensive database manipulation and I came across this issue where if I run sql queries through hibernate but not using the MQL approach, the view of the database doesn't appear correct. Specifically the code uses the hibernate in the more appropriate manner in most cases but there are places where someone decided to just execute sql. I don't like that they did this but at this point "it is what it is". I found an explanation that seems to explain it but all the examples are wrt actually getting and managing the transaction in the code. We are using the

六、Storm的高级原语之Transactional Topology

蓝咒 提交于 2019-11-29 05:59:57
1、什么是Transactional Topology? ○ 是一个每个tuple仅被处理一次的框架 ○ 由Storm0.7引入,于Storm0.9被弃用,被triden取而代之 ○ 底层依靠spout\bolt\topology\stream抽象的一个特性 2、Transactional Topology设计思路 ○ 一次只处理一次tuple 基于Storm处理tuple失败时会重发(replay),如何确保replay的记录不被重复记录,换句话说就是如何保证tuple仅被处理一次,这就依赖于一个称作强顺序性的思想。 强顺序性:每个tuple与一个transaction id相关联,transaction id实际就是一个数字,每一个tuple都有一个按照顺序的transaction id(例如:tuple1的transaction id 为 1,tuple2的transaction id 为 2,...以此类推), 只有当前的tuple处理并存储完毕,下一个tuple(处于等待状态)才能进行存储, tuple被存储时连同transaction id一并存储,此时考虑两种情况: tuple处理失败时:重新发送一个和原来一模一样的transaction id tuple处理成功时:发送的transaction id会和存储的transaction id对比

Spring @Transaction not starting transactions

我的梦境 提交于 2019-11-29 01:29:49
I am using Spring 3 with Hibernate 3. I am trying to configure Spring declarative transaction, but no matter what I try, Spring transaction is not getting started. Here is my configuration File: applicationContext-hibernate.xml <tx:annotation-driven transaction-manager="txManager" /> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="mdbDataSource" class="org.apache.commons.dbcp.BasicDataSource"> ... </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3

Entities Not Persisting - Spring + Hibernate + JPA

坚强是说给别人听的谎言 提交于 2019-11-28 21:57:36
I'm using Spring + Hibernate + JPA and I have a situation where I can't get my entities to persist to the database. I've set up a service class that is annotated with @Transactional. It uses a DAO that contains an injected EntityManager. When I call the function on the service object I see a bunch of selects for the reads the DAO is doing, but no updates/deletes as a result of merges and removes issued by my DAO. Surely there's something wrong with my setup, but I can't see it. persistence.xml <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001

Why use @Transactional with @Service instead of with @Controller

流过昼夜 提交于 2019-11-28 18:49:33
I have seen many comments in stack-overflow articles I found certain things about either @Transactional use with @Service or with @Controller "Usually, one should put a transaction at the service layer." "The normal case would be to annotate on a service layer level" "Think transactions belong on the Service layer. It's the one that knows about units of work and use cases. It's the right answer if you have several DAOs injected into a Service that need to work together in a single transaction." [Source] Drawback to use @transactional with @service layer If I had 2 methods for example saveUser(

Spring Propagation examples in layman's terms

落爺英雄遲暮 提交于 2019-11-28 14:39:42
问题 The Spring docs do a fantastic job of describing transactional propagation properties. However, I was wondering if there are any well-known, real-world examples available which describe each of these properties more thoroughly in layman's terms? 回答1: PROPAGATION_REQUIRED class Service { @Transactional(propagation=Propagation.REQUIRED) public void doSomething() { // access a database using a DAO } } When doSomething() is called it will start a new transaction if the caller has not already

Declarative transactions (@Transactional) doesn't work with @Repository in Spring

只愿长相守 提交于 2019-11-28 11:15:49
I'm trying to make simple application using Spring, JPA and embedded H2 database. Recently I've come across this strange issue with declarative transactions. They just doesn't commit if I autowire my DAO with @Repository annotation. More specifically I get exception on flush: javax.persistence.TransactionRequiredException: Exception Description: No transaction is currently active Here is my setup: persistence.xml <persistence-unit name="schedulePU" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <exclude-unlisted-classes>false</exclude

Spring @Transactional Annotation : Self Invocation

☆樱花仙子☆ 提交于 2019-11-28 10:22:38
I know when a transactional method is called from inside the same class it wouldn't be run in a transaction. Spring creates a proxy for transactional methods and wraps them in a try-catch block and rolls back if an exception occurs. Consider the following scenario: @Transactional public void saveAB(A a, B b) { saveA(a); saveB(b); } @Transactional public void saveA(A a) { dao.saveA(a); } @Transactional public void saveB(B b) { dao.saveB(b); } Assume saveAB is called from another object and an exception occurred in saveB, so saveA completed successfully but saveB did not. To my knowledge even