Sto cercando di eseguire questo codice JPA/EJB di base:"entità indipendente passato al persistere di errore" con il codice di JPA/EJB
public static void main(String[] args){
UserBean user = new UserBean();
user.setId(1);
user.setUserName("name1");
user.setPassword("passwd1");
em.persist(user);
}
ottengo questo errore:
javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.JPA.Database
Tutte le idee?
che cerco su internet e il motivo per cui ho trovato è stato:
This was caused by how you created the objects, i.e. If you set the ID property explicitly. Removing ID assignment fixed it.
ma non ho capito, che cosa dovrò modificare per ottenere il codice di lavoro?
Se si utilizzano i generici, non è necessario utilizzare "targetEntity = Photo.class" – Rollerball
hi, dopo aver impostato l'oggetto album su foto1 e foto2 ... quale oggetto è necessario salvare l'elenco di foto o album? –