Package com.github.zhangkaitao.shiro.chapter18.entity

Examples of com.github.zhangkaitao.shiro.chapter18.entity.User


            em.getTransaction().begin();
            Query q = em.createNamedQuery("User.login");
            q.setParameter("email", email);
            q.setParameter("pass", password);
           
            User user = null;
            List result = q.getResultList();
            if(result.size() == 1){
                user = (User)result.get(0);
                return user;
             }
View Full Code Here


        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            User createrUserId = courses.getCreaterUserId();
            if (createrUserId != null) {
                createrUserId = em.getReference(createrUserId.getClass(), createrUserId.getId());
                courses.setCreaterUserId(createrUserId);
            }
            List<Lecture> attachedLectureList = new ArrayList<Lecture>();
            for (Lecture lectureListLectureToAttach : courses.getLectureList()) {
                lectureListLectureToAttach = em.getReference(lectureListLectureToAttach.getClass(), lectureListLectureToAttach.getId());
                attachedLectureList.add(lectureListLectureToAttach);
            }
            courses.setLectureList(attachedLectureList);
            List<Enrollment> attachedEnrollmentList = new ArrayList<Enrollment>();
            for (Enrollment enrollmentListEnrollmentToAttach : courses.getEnrollmentList()) {
                enrollmentListEnrollmentToAttach = em.getReference(enrollmentListEnrollmentToAttach.getClass(), enrollmentListEnrollmentToAttach.getId());
                attachedEnrollmentList.add(enrollmentListEnrollmentToAttach);
            }
            courses.setEnrollmentList(attachedEnrollmentList);
            em.persist(courses);
            if (createrUserId != null) {
                createrUserId.getCoursesList().add(courses);
                createrUserId = em.merge(createrUserId);
            }
            for (Lecture lectureListLecture : courses.getLectureList()) {
                Courses oldCourseIdOfLectureListLecture = lectureListLecture.getCourseId();
                lectureListLecture.setCourseId(courses);
View Full Code Here

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

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

TOP

Related Classes of com.github.zhangkaitao.shiro.chapter18.entity.User

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.