find « Transaction « JPA Q&A





1. EJB Find persisted data in single transaction    stackoverflow.com

Let's say i have two tables in db: Car and Part. Car owns arbitrialy number of parts. Because i use EJB 3.0 i have entity beans for Car and Part and Car ...

2. Hibernate calls flush on find- causes not-null error    stackoverflow.com

I have a process which updates a tree to the database, and in doing so, performs reads to check for duplicates entities. I'm finding that trying to do a criteria.uniqueResult() midway through ...

3. Updating in a REQUIRES_NEW then finding in a different transaction returns old data. Why?    stackoverflow.com

This question is best described by a picture I think. I hope someone can help me. Thanksalt text

4. jpa 2 hibernate setting a lock on EntityManager.find    stackoverflow.com

I'm doing a few testcases on an hibernate project: when I call

EntityManager em = getEntityManager();
em.find(Foo.class, 1)
I get the entity as I expect, but when I invoke:
EntityManager em = getEntityManager();
em.find(Foo.class, 1, LockModeType.WRITE)
I'm ...

5. How to define an non-JTA datasource for JPA-Hibernate? org.hibernate.connection.DatasourceConnectionProvider - Could not find datasource:    stackoverflow.com

I am trying to change my web-app's JDBC code to JPA using Hibernate as provider. I am using Eclipse IDE. In that i have defined a MySQL data source. I added ...

6. Help me find the deadlock    stackoverflow.com

This is the first time I see this code myself where we are getting deadlock.

Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction
Here is the code: (Java/pseudocode)
// This function inside ...

7. org.hibernate.exception.JDBCConnectionException: could not insert, How To Find the problem in a production enviroment    stackoverflow.com

Where do you start when you have these problems? I'm having problems recreating these error in my development environment. We are running this code on resin server. And we have plugins ...

8. Find or create within existing transaction    forum.hibernate.org

I need to write a method which can find or create an object based on a unique but non-primary key. As an example say I have a Person class as defined below: Code: public class Person { @Id @GeneratedValue(strategy = IDENTITY) private int id; @NaturalId ...





10. Is it necessary to wrap a simple find() in a transaction?    forum.hibernate.org

Is this considered a 'best practice' for some reason? Why would this be? Example: Transaction tx = session.beginTransaction(); List blahList = session.find("from Blah"); tx.commit(); Not sure why I would 'need' to do this, but lots of examples in the manual do it this way. If I do have to do this for some reason, do I also need to rollback() if ...

11. Find a newly inserted record in the same transaction    forum.hibernate.org

I am using Oracle 9i and have a table that generates the primary key using an insert trigger. In my Java code, I create a new object and save it to the database then, in the same transaction, I want to look up the inserted record by its name field to get the generated primary key. THe idea is begin transaction ...

12. find method in different transactions    forum.hibernate.org

Hi everybody, The problem that i am facing is the following: I have two different transaction: A and B. 1.I start the trans A ( in the debug mode ) and in the middle of this transaction, i also start trans B that modifies some data. 2. I commit the transaction B. 3.I try to see the modifications in trans A ...

13. Concurrent "find or create" design issue    forum.hibernate.org

Hi, I have a design issue in my code, I need to do a "find or create" an entity in massive concurrent code. My goal is to rely on DB locking mechanism to handle this and avoid restarting the whole transaction in case of a concurrent issue (I have to handle errors...) : Imagine a table Foo with : ID PRIMARY ...