AnsweredAssumed Answered

EnrollmentPersister throwing PersistenceException after upgrading to SaaS

Question asked by cg0079143 on Mar 7, 2019

Inside our custom building block we are trying to update a user's enrolment availability and role but we are receiving the following exception while saving the record:

 

"blackboard.persist.PersistenceException: A database error occurred."

 

The following code is being used:

 

import blackboard.persist.course.CourseDbLoader;

import blackboard.persist.user.UserDbLoader;

import blackboard.data.user.User;

import blackboard.data.course.Course;

import blackboard.admin.data.course.Enrollment;

import blackboard.data.course.CourseMembership.Role;

import blackboard.admin.persist.course.EnrollmentLoader;

import blackboard.admin.persist.course.EnrollmentPersister;

 

UserDbLoader _userLoader = UserDbLoader.Default.getInstance();

CourseDbLoader _courseLoader = CourseDbLoader.Default.getInstance();

EnrollmentLoader _enrolmentLoader = EnrollmentLoader.Default.getInstance();

EnrollmentPersister _enrolmentPersister = EnrollmentPersister.Default.getInstance();

 

User user = _userLoader.loadByUserName(username);

Course course = _courseLoader.loadByCourseId(courseId);

Boolean active = false;

 

Enrollment enrolment = new Enrollment();

enrolment.setPersonBatchUid(user.getBatchUid());

enrolment.setCourseSiteBatchUid(course.getBatchUid());

 

List<Enrollment> enrolmentList = _enrolmentLoader.load(enrolment);

enrolment = enrolmentList.get(0);

enrolment.setRole(Role.STUDENT);

enrolment.setIsAvailable(active);

 

_enrolmentPersister.save(enrolment);

 

This code used to work before upgrading to SaaS but is no longer working.

 

Please help us to understand what the error is and how we can fix this.

Outcomes