AnsweredAssumed Answered

CourseMembershipDbPersister not finding deleteByCourseIdAndUserId

Question asked by as0045500 on Feb 15, 2017

Hi,

 

On this link: Building Blocks API 3000.1.0 inside CourseMembershipDbPersister there is a method called deleteByCourseIdAndUserId. I already imported the blackboard.persist.* but can't acess this particular method.

 

I'm using 2016 Q2 CU2 VM.

 

public static void removeUserOnCourse(Course course, User user) throws PersistenceException, ValidationException

  {

 

  BbPersistenceManager pm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();

  CourseMembershipDbPersister persister = (CourseMembershipDbPersister) pm.getPersister( CourseMembershipDbPersister.TYPE );

 

 

  persister.deleteByCourseIdAndUserId(course.getId(), user.getId());

   * The method deleteByCourseIdAndUserId(Id) is undefined for the type CourseMembershipDbPersister

 

  }

When i change to deleteByCourseId it works.

 

Any advice?

 

i'm trying to achieve: remove a particular user from a particular course.

 

Edit: Achieved what i wanted, it was a easy fix:

 

BbPersistenceManager pm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();

  CourseMembershipDbPersister persister = (CourseMembershipDbPersister) pm.getPersister( CourseMembershipDbPersister.TYPE );

  CourseMembershipDbLoader cmLoader = (CourseMembershipDbLoader) bbPm.getLoader(CourseMembershipDbLoader.TYPE);

 

  CourseMembershipDbLoader myMembership = cmLoader.loadByCourseAndUserId(course..getId(), user.getId());

 

  persister.deleteById(myMembership.getId());

Outcomes