Package entity

Examples of entity.Comments


        Enrollment enrollment = enrollentJPAController.findEnrollment(userID, courseID);

        boolean success = false;
       
        if (enrollment != null) {
            Comments comments = new Comments();
            comments.setEnrollmentId(enrollment);
            comments.setSysdate(new Date());
            comments.setComment(comment);
           
            CommentsJpaController commentsJPAContoller = new CommentsJpaController();
            commentsJPAContoller.create(comments);
           
            success = true;
View Full Code Here


        //********************************
       
        // Second generate a map list of comments
        ArrayList commentMapList = new ArrayList();
        for (Iterator<Comments> it = commentsList.iterator(); it.hasNext();) {
            Comments comment = it.next();
           
            Map commentMap = new HashMap();
            commentMap.put("commentID",         new Integer(comment.getId()));
            commentMap.put("commentDetail",     new String(comment.getComment()));
            commentMap.put("commentDate",       new String(comment.getSysdate().toString()));
            commentMap.put("commentUserName",   new String(comment.getEnrollmentId().getUserId().getName()));
            commentMapList.add(commentMap);
        }

        //********************************
       
View Full Code Here

        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) {
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Commentrates persistentCommentrates = em.find(Commentrates.class, commentrates.getId());
            Comments commentsOld = persistentCommentrates.getComments();
            Comments commentsNew = commentrates.getComments();
            List<String> illegalOrphanMessages = null;
            if (commentsNew != null && !commentsNew.equals(commentsOld)) {
                Commentrates oldCommentratesOfComments = commentsNew.getCommentrates();
                if (oldCommentratesOfComments != null) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("The Comments " + commentsNew + " 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);
            }
            if (commentsNew != null) {
                commentsNew = em.getReference(commentsNew.getClass(), commentsNew.getId());
                commentrates.setComments(commentsNew);
            }
            commentrates = em.merge(commentrates);
            if (commentsOld != null && !commentsOld.equals(commentsNew)) {
                commentsOld.setCommentrates(null);
                commentsOld = em.merge(commentsOld);
            }
            if (commentsNew != null && !commentsNew.equals(commentsOld)) {
                commentsNew.setCommentrates(commentrates);
                commentsNew = em.merge(commentsNew);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            String msg = ex.getLocalizedMessage();
View Full Code Here

                commentrates = em.getReference(Commentrates.class, id);
                commentrates.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The commentrates with id " + id + " no longer exists.", enfe);
            }
            Comments comments = commentrates.getComments();
            if (comments != null) {
                comments.setCommentrates(null);
                comments = em.merge(comments);
            }
            em.remove(commentrates);
            em.getTransaction().commit();
        } finally {
View Full Code Here

                enrollmentId = em.getReference(enrollmentId.getClass(), enrollmentId.getId());
                comments.setEnrollmentId(enrollmentId);
            }
            em.persist(comments);
            if (commentrates != null) {
                Comments oldCommentsOfCommentrates = commentrates.getComments();
                if (oldCommentsOfCommentrates != null) {
                    oldCommentsOfCommentrates.setCommentrates(null);
                    oldCommentsOfCommentrates = em.merge(oldCommentsOfCommentrates);
                }
                commentrates.setComments(comments);
                commentrates = em.merge(commentrates);
            }
View Full Code Here

    public void edit(Comments comments) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Comments persistentComments = em.find(Comments.class, comments.getId());
            Commentrates commentratesOld = persistentComments.getCommentrates();
            Commentrates commentratesNew = comments.getCommentrates();
            Enrollment enrollmentIdOld = persistentComments.getEnrollmentId();
            Enrollment enrollmentIdNew = comments.getEnrollmentId();
            List<String> illegalOrphanMessages = null;
            if (commentratesOld != null && !commentratesOld.equals(commentratesNew)) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("You must retain Commentrates " + commentratesOld + " since its comments field is not nullable.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (commentratesNew != null) {
                commentratesNew = em.getReference(commentratesNew.getClass(), commentratesNew.getId());
                comments.setCommentrates(commentratesNew);
            }
            if (enrollmentIdNew != null) {
                enrollmentIdNew = em.getReference(enrollmentIdNew.getClass(), enrollmentIdNew.getId());
                comments.setEnrollmentId(enrollmentIdNew);
            }
            comments = em.merge(comments);
            if (commentratesNew != null && !commentratesNew.equals(commentratesOld)) {
                Comments oldCommentsOfCommentrates = commentratesNew.getComments();
                if (oldCommentsOfCommentrates != null) {
                    oldCommentsOfCommentrates.setCommentrates(null);
                    oldCommentsOfCommentrates = em.merge(oldCommentsOfCommentrates);
                }
                commentratesNew.setComments(comments);
                commentratesNew = em.merge(commentratesNew);
            }
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Comments comments;
            try {
                comments = em.getReference(Comments.class, id);
                comments.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The comments with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            Commentrates commentratesOrphanCheck = comments.getCommentrates();
            if (commentratesOrphanCheck != null) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Comments (" + comments + ") cannot be destroyed since the Commentrates " + commentratesOrphanCheck + " in its commentrates field has a non-nullable comments field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Enrollment enrollmentId = comments.getEnrollmentId();
            if (enrollmentId != null) {
                enrollmentId.getCommentsList().remove(comments);
                enrollmentId = em.merge(enrollmentId);
            }
            em.remove(comments);
View Full Code Here

TOP

Related Classes of entity.Comments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.