Skip to content
Advertisement

Tag: transactions

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

Override transactional method

I have method M with @Transactional in service A. I have service B extends A with overrided method M. Will be overrided method M still transactional? Or I should add there @Transactional? Answer What you are actually asking : is the @Transactional annotation on the method inherited. Short answer : no. Annotations on methods are never inherited. Long answer :

Where is the best place to begin transaction using Hibernate in a tired web application with Struts 2?

I got this Java web application which uses Struts 2 and Hibernate. In the most upper layer comprises of the Struts 2 action classes. Then there are my business logic classes which are responsible for the logic of the application. Finally there is a DAO layer (called Database Bridge) which is responsible for communicating with the database. Currently I open

Why do I need Transaction in Hibernate for read-only operations?

Why do I need Transaction in Hibernate for read-only operations? Does the following transaction put a lock in the DB? Example code to fetch from DB: Can I use session.close() instead of tx.commit()? Answer Transactions for reading might look indeed strange and often people don’t mark methods for transactions in this case. But JDBC will create transaction anyway, it’s just

How to start a transaction in JDBC?

Connection.setTransactionIsolation(int) warns: Note: If this method is called during a transaction, the result is implementation-defined. This bring up the question: how do you begin a transaction in JDBC? It’s clear how to end a transaction, but not how to begin it. If a Connection starts inside in a transaction, how are we supposed to invoke Connection.setTransactionIsolation(int) outside of a transaction

Advertisement