method « EntityManager « JPA Q&A





1. Is Hibernate entity callback methods are only called by using EntityManager    stackoverflow.com

Hi I used Spring's HibernateTemplate to save entity, I also add call back method like this

@PrePersist
  public void prePersist() {
    setCreateDate(new Date());
  }
but I found this callback ...

2. Hibernate v3.6 : Issue with the EntityManager method "refresh"    stackoverflow.com

The following code throws an exception when invoking "em.refresh(p)":

1: EntityManager em = emf.createEntityManager();
2: em.getTransaction().begin();
3:
4: Product p = new Product("J&D", 35.0,"Whisky");
5: em.persist(p);
6:
7: em.refresh(p);
8: em.getTransaction().commit();
9: em.close();
When debugging the code, we see that Hibernate ...

3. Does EntityManager's find() method create new instance of JPA class?    stackoverflow.com

I'm a bit confused. The question is in title, and here's why I'm asking. I have JSF + JPA web-application running on a single VM. And an JPA class has @Transient ...

5. Passing EntityManager reference between methods doesn't work    forum.hibernate.org

Newbie Joined: Sun Jul 05, 2009 9:59 pm Posts: 6 I apologize in advance for a lengthy post but I guess I need to support my query with code. I am coding for a system which has 12 database instances. All databases have the same number and name of tables but the data is different (of course). Depending on a URL ...

6. Issue with the EntityManager method "refresh" and Hibernate    forum.hibernate.org

Hey, The following code throws an exception when invoking "em.refresh(p)": 1: EntityManager em = emf.createEntityManager(); 2: em.getTransaction().begin(); 3: 4: Product p = new Product("J&D", 35.0,"Whisky"); 5: em.persist(p); 6: 7: em.refresh(p); 8: em.getTransaction().commit(); 9: em.close(); When debugging the code, we see that Hibernate didn't write the record into the DB at line 6. He does is like foreseen - when it's required, ...

7. EntityManager's methods doubts    forum.hibernate.org

8. Semantics of EntityManager.contains() method    forum.hibernate.org

Hi all, I'm having a problem with hibernate's implementation of the EntityManager interface - specifically the contains() method, and I'd appreciate any help you can offer. My application works with a complex graph of objects, and implements the session per request pattern, using detached objects while the graph is constructed and merging when it comes to persist. This application works exclusively ...