mysql « EntityManager « JPA Q&A





1. Persisting a new but identical entity with JPA reporting duplicate entry    stackoverflow.com

I have a JPA project connected to a MySQL database where my entity object is mapped to a table with a constraint on 2 columns. That is:

@Entity
@Table(name = "my_entity")
class MyEntity {
 ...

2. What is the proper way to ensure EntityManager connections are closed?    stackoverflow.com

There are 19 methods in our DAO layer, each is some variation of this:

public TicketProp saveTicketProp(TicketProp prop) {
    EntityManager em = this.emf.createEntityManager();
    try {
  ...

3. EntityManager.find method leading to MySQLIntegrityConstraintViolationException    stackoverflow.com

When I execute EntityManager.find() the following exception is thrown:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'date' in field list is ambiguous
The class (Profile) I'm trying to find has a bi-directional ...

4. Can I share a persistence entity manager factory across multiple JADE agents    stackoverflow.com

I've got a container of JADE agents, one of which currently interfaces with a mysql database using hibernate/persistence and I now want to extend the database access to other agents - ...