getTransaction « Transaction « JPA Q&A





1. before calling session.gettransaction, do I have to ensure one exists?    stackoverflow.com

before calling session.gettransaction, do I have to ensure one exists? if so, how do I check if there is a current uncommitted transaction in the session?

2. When calling JPA's remove() : "A JTA EntityManager cannot use getTransaction()"    stackoverflow.com

I've been using StackOverflow for a while, but this is my first question here. I am new to JPA, I created a "Role" entity, I would like to do CRUD operations ...

3. Hibernate: Whether session.get() needs session.getTransaction().commit()?    stackoverflow.com

The Code is:

    Configuration conf = new Configuration();
    SessionFactory fact = conf.configure().buildSessionFactory();
    Session session = fact.getCurrentSession();
    session.beginTransaction();
   ...

4. EJBException when calling entityManager.getTransaction()    stackoverflow.com

This is probably something trivial, but I'd love some help. I get:

 javax.ejb.EJBException: java.lang.IllegalStateException: Illegal to call this method from injected, managed EntityManager 
 11:54:37,105 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
 11:54:37,105 ERROR [STDERR] ...

5. entityManager.getTransaction().rollback() detaches entities?    stackoverflow.com

I have the following piece of code:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("test")
EntityManager entityManager = emf.createEntityManager()
User user = entityManager.find(User.class, 0);
entityManager.getTransaction().begin();
entityManager.getTransaction().rollback();
entityManager.refresh(user);
This throws an IllegalArgumentException on the fourth line saying "Entity not managed". If I change ...

6. Is there a difference between getTransaction().begin()/.commit() and joinTransaction() with JPA2/EclipseLink?    stackoverflow.com

I'm using JPA2 with annotations and EclipseLink and I'm wondering if there is a difference between

EntityManager em = ...
// Some action
em.joinTransaction();
em.close();
and
EntityManager em = PU.entityManager();
em.getTransaction().begin();
// Some action
em.getTransaction().commit();
em.close();
and which one should I generally ...

7. em.getTransaction.begin() vs @Transactional    forum.hibernate.org

All, I have a question regarding using the @Transactional annotation vs having to wrap my EntityManager.persist(entity) inside of a EntityManager.getTransaction().begin() and then EntityManager.commit(); For instance, given the following method: Code: public class someDao { EntityManager em; @Transactional(readOnly=false) public void persist(Object entity) { ...

8. Invalid session.getTransaction()?    forum.hibernate.org

Why would that be easier? You call beginTransaction() to get a Transaction object and start a transaction at the same time. It does not make much sense to return null or return a Transaction object that isn't already active. The latter might have some uses, we are discussing the asymetry in the API right now. However, "null" is not an option. ...

9. getTransaction() error in the Hibernate Tutorial    forum.hibernate.org

Hi there, I am following the first tutorial that comes with Hibernate, I get the following error while compiling the code from EventManager.java file. D:\HiberExam\src\events\EventManager.java:33: cannot find symbol symbol : method getTransaction() location: interface org.hibernate.Session session.getTransaction().commit(); ^ 1 error Now I am not sure how to fix this as the code I am using is also available online. I would appreciate ...





10. Java.lang.NoSuchMethodError at session.getTransaction() call    forum.hibernate.org

Hi , I am making a simple demo application using JBoss and Hibernate3 Somewhere in my application i have a code like this...... ////////////////////////// session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.getTransaction() ;//Java.lang.NoSuchMethodError ///////////////////////////////// The problem is that my application crashes at runtime at the statement Transaction tx = session.getTransaction() ; The stack trace gives following message , java.lang.NoSuchMethodError: org.hibernate.Session.getTransaction()Lorg/hibernate/Transaction; Have read ...

11. HelpError: A JTA EntityManager can not use getTransaction ()    forum.hibernate.org

java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction() at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324) at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:53) at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:330) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:369) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:340) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625) at com.aam2.mailingplatform.repository.IPDao$$EnhancerByCGLIB$$4af933d7.getAll() at ...