method « Transaction « JPA Q&A





1. Hibernate transaction annotations in source -- difference between class and method level use?    stackoverflow.com

I am trying to understand what the difference in behavior is when applying the transaction annotation to a class vs. method (and at the property level even?). Does anyone have a ...

2. Is there a scenario when you would put @Transactional to a method that only retrieves data?    stackoverflow.com

For example this service class' method below:

@Transactional
public void findDiscountedItems() {
   List<Item> items = itemDao.findItems();
   List<Item> discountedItems = new ArrayList<Item>();
   for (Item i: items) {
  ...

3. Is it ever good practice to have non-transactional EJB "read" methods?    stackoverflow.com

This is a very humble question. There are some articles that indicate that one should always use database transactions, even for simple read operations. Here is an arbitrary example that makes ...

4. @Schedule method doesn't commit transaction    stackoverflow.com

I have a schedule method on a bean which sends emails taking messages to send from JPA query. Messages are sent and its status updated (AKA message.setSent(true)), I can see the UPDATE ...

5. explicit flush() in a transactional method will update database or not    stackoverflow.com

in my app i have a service layer where the spring transaction boundary is declared for all the methods inside this service. service layer interally contact dao. here my question if ...

6. Is it possible to mark one method of an entire @Transactional class as non-transactional    stackoverflow.com

I need to maintain the transaction manually in a method of a class which was marked as @Transactional. If I try to do this now, an exception is being thrown (most ...

7. what is the purpose of session.lock method in Hibernate    stackoverflow.com

I am going through lock method of hibernate. I did not get what we are trying to achieve through this method.

 p1  = (Person)session. get(Person.class,1);// person name ...

8. Does Hibernate support transaction or method locking?    forum.hibernate.org

Hi, I'm a J2EE developer with experience using entity beans, but I'm new to Hibernate and have one question. With entity beans, I often rely on method locking and transaction locking to ensure "synchronized" behavior: Method Locking Method locking ensures that only one thread of execution at a time can invoke on a given Entity Bean. Transaction Locking Transaction locking ensures ...

9. how to commit a transaction in the middle of EJB3 method    forum.hibernate.org

public @Stateless class XXXBean { @PersistenceContext(unitName="ImagineDB") private EntityManager manager; public void someMethod() { Dog dog = new Dog(); //dog is an entity bean; manager.persist(dog); manager.flush(); //here I want new transaction manager.getTransaction().commit(); //this commands fails Cat cat = new Cat(); manager.persist(cat); ...





11. method shows error You cannot commit with autocommit set!    forum.hibernate.org

hi , For testing my application we accessed the login page from multiple nodes at the same time . a) some time we all are able to login successfully b) but at sometime it shows an error -"You cannot commit with autocommit set!" when we refresh the page then it gets logged in. Is there any way by which we can ...