return emf.createEntityManager();
}
public void create(Commentrates commentrates) throws IllegalOrphanException, PreexistingEntityException, Exception {
List<String> illegalOrphanMessages = null;
Comments commentsOrphanCheck = commentrates.getComments();
if (commentsOrphanCheck != null) {
Commentrates oldCommentratesOfComments = commentsOrphanCheck.getCommentrates();
if (oldCommentratesOfComments != null) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("The Comments " + commentsOrphanCheck + " already has an item of type Commentrates whose comments column cannot be null. Please make another selection for the comments field.");
}
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Comments comments = commentrates.getComments();
if (comments != null) {
comments = em.getReference(comments.getClass(), comments.getId());
commentrates.setComments(comments);
}
em.persist(commentrates);
if (comments != null) {
comments.setCommentrates(commentrates);
comments = em.merge(comments);
}
em.getTransaction().commit();
} catch (Exception ex) {
if (findCommentrates(commentrates.getId()) != null) {