Package entity

Examples of entity.Courses


        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Lecture persistentLecture = em.find(Lecture.class, lecture.getId());
            Courses courseIdOld = persistentLecture.getCourseId();
            Courses courseIdNew = lecture.getCourseId();
            if (courseIdNew != null) {
                courseIdNew = em.getReference(courseIdNew.getClass(), courseIdNew.getCourseId());
                lecture.setCourseId(courseIdNew);
            }
            lecture = em.merge(lecture);
            if (courseIdOld != null && !courseIdOld.equals(courseIdNew)) {
                courseIdOld.getLectureList().remove(lecture);
                courseIdOld = em.merge(courseIdOld);
            }
            if (courseIdNew != null && !courseIdNew.equals(courseIdOld)) {
                courseIdNew.getLectureList().add(lecture);
                courseIdNew = em.merge(courseIdNew);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            String msg = ex.getLocalizedMessage();
View Full Code Here


                lecture = em.getReference(Lecture.class, id);
                lecture.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The lecture with id " + id + " no longer exists.", enfe);
            }
            Courses courseId = lecture.getCourseId();
            if (courseId != null) {
                courseId.getLectureList().remove(lecture);
                courseId = em.merge(courseId);
            }
            em.remove(lecture);
            em.getTransaction().commit();
        } finally {
View Full Code Here

            User userId = enrollment.getUserId();
            if (userId != null) {
                userId = em.getReference(userId.getClass(), userId.getId());
                enrollment.setUserId(userId);
            }
            Courses courseId = enrollment.getCourseId();
            if (courseId != null) {
                courseId = em.getReference(courseId.getClass(), courseId.getCourseId());
                enrollment.setCourseId(courseId);
            }
            List<Comments> attachedCommentsList = new ArrayList<Comments>();
            for (Comments commentsListCommentsToAttach : enrollment.getCommentsList()) {
                commentsListCommentsToAttach = em.getReference(commentsListCommentsToAttach.getClass(), commentsListCommentsToAttach.getId());
                attachedCommentsList.add(commentsListCommentsToAttach);
            }
            enrollment.setCommentsList(attachedCommentsList);
            em.persist(enrollment);
            if (courserates != null) {
                Enrollment oldEnrollmentOfCourserates = courserates.getEnrollment();
                if (oldEnrollmentOfCourserates != null) {
                    oldEnrollmentOfCourserates.setCourserates(null);
                    oldEnrollmentOfCourserates = em.merge(oldEnrollmentOfCourserates);
                }
                courserates.setEnrollment(enrollment);
                courserates = em.merge(courserates);
            }
            if (userId != null) {
                userId.getEnrollmentList().add(enrollment);
                userId = em.merge(userId);
            }
            if (courseId != null) {
                courseId.getEnrollmentList().add(enrollment);
                courseId = em.merge(courseId);
            }
            for (Comments commentsListComments : enrollment.getCommentsList()) {
                Enrollment oldEnrollmentIdOfCommentsListComments = commentsListComments.getEnrollmentId();
                commentsListComments.setEnrollmentId(enrollment);
View Full Code Here

            Enrollment persistentEnrollment = em.find(Enrollment.class, enrollment.getId());
            Courserates courseratesOld = persistentEnrollment.getCourserates();
            Courserates courseratesNew = enrollment.getCourserates();
            User userIdOld = persistentEnrollment.getUserId();
            User userIdNew = enrollment.getUserId();
            Courses courseIdOld = persistentEnrollment.getCourseId();
            Courses courseIdNew = enrollment.getCourseId();
            List<Comments> commentsListOld = persistentEnrollment.getCommentsList();
            List<Comments> commentsListNew = enrollment.getCommentsList();
            List<String> illegalOrphanMessages = null;
            if (courseratesOld != null && !courseratesOld.equals(courseratesNew)) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("You must retain Courserates " + courseratesOld + " since its enrollment field is not nullable.");
            }
            for (Comments commentsListOldComments : commentsListOld) {
                if (!commentsListNew.contains(commentsListOldComments)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Comments " + commentsListOldComments + " since its enrollmentId field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (courseratesNew != null) {
                courseratesNew = em.getReference(courseratesNew.getClass(), courseratesNew.getId());
                enrollment.setCourserates(courseratesNew);
            }
            if (userIdNew != null) {
                userIdNew = em.getReference(userIdNew.getClass(), userIdNew.getId());
                enrollment.setUserId(userIdNew);
            }
            if (courseIdNew != null) {
                courseIdNew = em.getReference(courseIdNew.getClass(), courseIdNew.getCourseId());
                enrollment.setCourseId(courseIdNew);
            }
            List<Comments> attachedCommentsListNew = new ArrayList<Comments>();
            for (Comments commentsListNewCommentsToAttach : commentsListNew) {
                commentsListNewCommentsToAttach = em.getReference(commentsListNewCommentsToAttach.getClass(), commentsListNewCommentsToAttach.getId());
                attachedCommentsListNew.add(commentsListNewCommentsToAttach);
            }
            commentsListNew = attachedCommentsListNew;
            enrollment.setCommentsList(commentsListNew);
            enrollment = em.merge(enrollment);
            if (courseratesNew != null && !courseratesNew.equals(courseratesOld)) {
                Enrollment oldEnrollmentOfCourserates = courseratesNew.getEnrollment();
                if (oldEnrollmentOfCourserates != null) {
                    oldEnrollmentOfCourserates.setCourserates(null);
                    oldEnrollmentOfCourserates = em.merge(oldEnrollmentOfCourserates);
                }
                courseratesNew.setEnrollment(enrollment);
                courseratesNew = em.merge(courseratesNew);
            }
            if (userIdOld != null && !userIdOld.equals(userIdNew)) {
                userIdOld.getEnrollmentList().remove(enrollment);
                userIdOld = em.merge(userIdOld);
            }
            if (userIdNew != null && !userIdNew.equals(userIdOld)) {
                userIdNew.getEnrollmentList().add(enrollment);
                userIdNew = em.merge(userIdNew);
            }
            if (courseIdOld != null && !courseIdOld.equals(courseIdNew)) {
                courseIdOld.getEnrollmentList().remove(enrollment);
                courseIdOld = em.merge(courseIdOld);
            }
            if (courseIdNew != null && !courseIdNew.equals(courseIdOld)) {
                courseIdNew.getEnrollmentList().add(enrollment);
                courseIdNew = em.merge(courseIdNew);
            }
            for (Comments commentsListNewComments : commentsListNew) {
                if (!commentsListOld.contains(commentsListNewComments)) {
                    Enrollment oldEnrollmentIdOfCommentsListNewComments = commentsListNewComments.getEnrollmentId();
View Full Code Here

            User userId = enrollment.getUserId();
            if (userId != null) {
                userId.getEnrollmentList().remove(enrollment);
                userId = em.merge(userId);
            }
            Courses courseId = enrollment.getCourseId();
            if (courseId != null) {
                courseId.getEnrollmentList().remove(enrollment);
                courseId = em.merge(courseId);
            }
            em.remove(enrollment);
            em.getTransaction().commit();
        } finally {
View Full Code Here

            if (createrUserId != null) {
                createrUserId.getCoursesList().add(courses);
                createrUserId = em.merge(createrUserId);
            }
            for (Lecture lectureListLecture : courses.getLectureList()) {
                Courses oldCourseIdOfLectureListLecture = lectureListLecture.getCourseId();
                lectureListLecture.setCourseId(courses);
                lectureListLecture = em.merge(lectureListLecture);
                if (oldCourseIdOfLectureListLecture != null) {
                    oldCourseIdOfLectureListLecture.getLectureList().remove(lectureListLecture);
                    oldCourseIdOfLectureListLecture = em.merge(oldCourseIdOfLectureListLecture);
                }
            }
            for (Enrollment enrollmentListEnrollment : courses.getEnrollmentList()) {
                Courses oldCourseIdOfEnrollmentListEnrollment = enrollmentListEnrollment.getCourseId();
                enrollmentListEnrollment.setCourseId(courses);
                enrollmentListEnrollment = em.merge(enrollmentListEnrollment);
                if (oldCourseIdOfEnrollmentListEnrollment != null) {
                    oldCourseIdOfEnrollmentListEnrollment.getEnrollmentList().remove(enrollmentListEnrollment);
                    oldCourseIdOfEnrollmentListEnrollment = em.merge(oldCourseIdOfEnrollmentListEnrollment);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here

    public void edit(Courses courses) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Courses persistentCourses = em.find(Courses.class, courses.getCourseId());
            User createrUserIdOld = persistentCourses.getCreaterUserId();
            User createrUserIdNew = courses.getCreaterUserId();
            List<Lecture> lectureListOld = persistentCourses.getLectureList();
            List<Lecture> lectureListNew = courses.getLectureList();
            List<Enrollment> enrollmentListOld = persistentCourses.getEnrollmentList();
            List<Enrollment> enrollmentListNew = courses.getEnrollmentList();
            List<String> illegalOrphanMessages = null;
            for (Enrollment enrollmentListOldEnrollment : enrollmentListOld) {
                if (!enrollmentListNew.contains(enrollmentListOldEnrollment)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Enrollment " + enrollmentListOldEnrollment + " since its courseId field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (createrUserIdNew != null) {
                createrUserIdNew = em.getReference(createrUserIdNew.getClass(), createrUserIdNew.getId());
                courses.setCreaterUserId(createrUserIdNew);
            }
            List<Lecture> attachedLectureListNew = new ArrayList<Lecture>();
            for (Lecture lectureListNewLectureToAttach : lectureListNew) {
                lectureListNewLectureToAttach = em.getReference(lectureListNewLectureToAttach.getClass(), lectureListNewLectureToAttach.getId());
                attachedLectureListNew.add(lectureListNewLectureToAttach);
            }
            lectureListNew = attachedLectureListNew;
            courses.setLectureList(lectureListNew);
            List<Enrollment> attachedEnrollmentListNew = new ArrayList<Enrollment>();
            for (Enrollment enrollmentListNewEnrollmentToAttach : enrollmentListNew) {
                enrollmentListNewEnrollmentToAttach = em.getReference(enrollmentListNewEnrollmentToAttach.getClass(), enrollmentListNewEnrollmentToAttach.getId());
                attachedEnrollmentListNew.add(enrollmentListNewEnrollmentToAttach);
            }
            enrollmentListNew = attachedEnrollmentListNew;
            courses.setEnrollmentList(enrollmentListNew);
            courses = em.merge(courses);
            if (createrUserIdOld != null && !createrUserIdOld.equals(createrUserIdNew)) {
                createrUserIdOld.getCoursesList().remove(courses);
                createrUserIdOld = em.merge(createrUserIdOld);
            }
            if (createrUserIdNew != null && !createrUserIdNew.equals(createrUserIdOld)) {
                createrUserIdNew.getCoursesList().add(courses);
                createrUserIdNew = em.merge(createrUserIdNew);
            }
            for (Lecture lectureListOldLecture : lectureListOld) {
                if (!lectureListNew.contains(lectureListOldLecture)) {
                    lectureListOldLecture.setCourseId(null);
                    lectureListOldLecture = em.merge(lectureListOldLecture);
                }
            }
            for (Lecture lectureListNewLecture : lectureListNew) {
                if (!lectureListOld.contains(lectureListNewLecture)) {
                    Courses oldCourseIdOfLectureListNewLecture = lectureListNewLecture.getCourseId();
                    lectureListNewLecture.setCourseId(courses);
                    lectureListNewLecture = em.merge(lectureListNewLecture);
                    if (oldCourseIdOfLectureListNewLecture != null && !oldCourseIdOfLectureListNewLecture.equals(courses)) {
                        oldCourseIdOfLectureListNewLecture.getLectureList().remove(lectureListNewLecture);
                        oldCourseIdOfLectureListNewLecture = em.merge(oldCourseIdOfLectureListNewLecture);
                    }
                }
            }
            for (Enrollment enrollmentListNewEnrollment : enrollmentListNew) {
                if (!enrollmentListOld.contains(enrollmentListNewEnrollment)) {
                    Courses oldCourseIdOfEnrollmentListNewEnrollment = enrollmentListNewEnrollment.getCourseId();
                    enrollmentListNewEnrollment.setCourseId(courses);
                    enrollmentListNewEnrollment = em.merge(enrollmentListNewEnrollment);
                    if (oldCourseIdOfEnrollmentListNewEnrollment != null && !oldCourseIdOfEnrollmentListNewEnrollment.equals(courses)) {
                        oldCourseIdOfEnrollmentListNewEnrollment.getEnrollmentList().remove(enrollmentListNewEnrollment);
                        oldCourseIdOfEnrollmentListNewEnrollment = em.merge(oldCourseIdOfEnrollmentListNewEnrollment);
                    }
                }
            }
            em.getTransaction().commit();
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Courses courses;
            try {
                courses = em.getReference(Courses.class, id);
                courses.getCourseId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The courses with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            List<Enrollment> enrollmentListOrphanCheck = courses.getEnrollmentList();
            for (Enrollment enrollmentListOrphanCheckEnrollment : enrollmentListOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Courses (" + courses + ") cannot be destroyed since the Enrollment " + enrollmentListOrphanCheckEnrollment + " in its enrollmentList field has a non-nullable courseId field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            User createrUserId = courses.getCreaterUserId();
            if (createrUserId != null) {
                createrUserId.getCoursesList().remove(courses);
                createrUserId = em.merge(createrUserId);
            }
            List<Lecture> lectureList = courses.getLectureList();
            for (Lecture lectureListLecture : lectureList) {
                lectureListLecture.setCourseId(null);
                lectureListLecture = em.merge(lectureListLecture);
            }
            em.remove(courses);
View Full Code Here

        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Courses courseId = coursetag.getCourseId();
            if (courseId != null) {
                courseId = em.getReference(courseId.getClass(), courseId.getCourseId());
                coursetag.setCourseId(courseId);
            }
            Tag tagId = coursetag.getTagId();
            if (tagId != null) {
                tagId = em.getReference(tagId.getClass(), tagId.getId());
                coursetag.setTagId(tagId);
            }
            List<Tagrates> attachedTagratesList = new ArrayList<Tagrates>();
            for (Tagrates tagratesListTagratesToAttach : coursetag.getTagratesList()) {
                tagratesListTagratesToAttach = em.getReference(tagratesListTagratesToAttach.getClass(), tagratesListTagratesToAttach.getId());
                attachedTagratesList.add(tagratesListTagratesToAttach);
            }
            coursetag.setTagratesList(attachedTagratesList);
            em.persist(coursetag);
            if (courseId != null) {
                courseId.getCoursetagList().add(coursetag);
                courseId = em.merge(courseId);
            }
            if (tagId != null) {
                tagId.getCoursetagList().add(coursetag);
                tagId = em.merge(tagId);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Coursetag persistentCoursetag = em.find(Coursetag.class, coursetag.getId());
            Courses courseIdOld = persistentCoursetag.getCourseId();
            Courses courseIdNew = coursetag.getCourseId();
            Tag tagIdOld = persistentCoursetag.getTagId();
            Tag tagIdNew = coursetag.getTagId();
            List<Tagrates> tagratesListOld = persistentCoursetag.getTagratesList();
            List<Tagrates> tagratesListNew = coursetag.getTagratesList();
            List<String> illegalOrphanMessages = null;
            for (Tagrates tagratesListOldTagrates : tagratesListOld) {
                if (!tagratesListNew.contains(tagratesListOldTagrates)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Tagrates " + tagratesListOldTagrates + " since its courseTagId field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (courseIdNew != null) {
                courseIdNew = em.getReference(courseIdNew.getClass(), courseIdNew.getCourseId());
                coursetag.setCourseId(courseIdNew);
            }
            if (tagIdNew != null) {
                tagIdNew = em.getReference(tagIdNew.getClass(), tagIdNew.getId());
                coursetag.setTagId(tagIdNew);
            }
            List<Tagrates> attachedTagratesListNew = new ArrayList<Tagrates>();
            for (Tagrates tagratesListNewTagratesToAttach : tagratesListNew) {
                tagratesListNewTagratesToAttach = em.getReference(tagratesListNewTagratesToAttach.getClass(), tagratesListNewTagratesToAttach.getId());
                attachedTagratesListNew.add(tagratesListNewTagratesToAttach);
            }
            tagratesListNew = attachedTagratesListNew;
            coursetag.setTagratesList(tagratesListNew);
            coursetag = em.merge(coursetag);
            if (courseIdOld != null && !courseIdOld.equals(courseIdNew)) {
                courseIdOld.getCoursetagList().remove(coursetag);
                courseIdOld = em.merge(courseIdOld);
            }
            if (courseIdNew != null && !courseIdNew.equals(courseIdOld)) {
                courseIdNew.getCoursetagList().add(coursetag);
                courseIdNew = em.merge(courseIdNew);
            }
            if (tagIdOld != null && !tagIdOld.equals(tagIdNew)) {
                tagIdOld.getCoursetagList().remove(coursetag);
                tagIdOld = em.merge(tagIdOld);
View Full Code Here

TOP

Related Classes of entity.Courses

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.