Package org.olat.core.commons.persistence

Examples of org.olat.core.commons.persistence.DB.createQuery()


      // Original comment has been deleted in the meantime. Don't delete it again.
      return 0;
    }
    DB db = DBFactory.getInstance();
    // First deal with all direct replies
    DBQuery query = db.createQuery("select comment from UserCommentImpl as comment where parent=:parent");
    query.setEntity("parent", comment);
    List<UserComment> replies = query.list();
    if (deleteReplies) {
      // Since we have a many-to-one we first have to recursively delete
      // the replies to prevent foreign key constraints
View Full Code Here


    query.append(" and ( p.name = '").append(AssessmentManager.SCORE);
    query.append("' or p.name = '").append(AssessmentManager.PASSED);
    query.append("' )");

    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query.toString());
    ICourse course = CourseFactory.loadCourse(ores);
    dbq.setLong("resid", course.getResourceableId().longValue());
    dbq.setString("resname", course.getResourceableTypeName());

    List res = dbq.list();
View Full Code Here

    boolean children = false;
    DB db = DBFactory.getInstance();
    Long message_id = m.getKey();
    String q = " select count(msg) from org.olat.modules.fo.MessageImpl msg where msg.parent = :input ";

    DBQuery query = db.createQuery(q);
    query.setLong("input", message_id.longValue());
    List result = query.list();
    int count = ((Long) result.get(0)).intValue();

    if (count > 0) {
View Full Code Here

   */
  public BGArea findBGArea(String areaName, BGContext groupContext) {
    DB db = DBFactory.getInstance();
    String q = "select area from org.olat.group.area.BGAreaImpl area " + " where area.name = :areaName"
        + " and area.groupContext = :context";
    DBQuery query = db.createQuery(q);
    query.setString("areaName", areaName);
    query.setEntity("context", groupContext);
    List areas = query.list();
    if (areas.size() == 0) {
      return null;
View Full Code Here

    String query = "select count(bgs) from "
      + "  org.olat.group.BusinessGroupImpl as bgs "
      + "  where "
      + "  bgs.groupContext = :context"
      + " and bgs.name in (:names)";
    DBQuery dbq = db.createQuery(query);
    dbq.setEntity("context", groupContext);   
    dbq.setParameterList("names", names);
    int result = ((Long) dbq.list().get(0)).intValue();
    //return false if none of the groups was found
    if (result == 0) return false;
View Full Code Here

   */
  private static boolean testIfGroupAlreadyExists(String name, String type, BGContext groupContext) {
    DB db = DBFactory.getInstance();
    String query = "select count(bgs) from " + "  org.olat.group.BusinessGroupImpl as bgs " + " where bgs.type = :type"
        + " and bgs.groupContext = :context" + " and bgs.name = :name";
    DBQuery dbq = db.createQuery(query);
    dbq.setString("type", type);
    dbq.setEntity("context", groupContext);
    dbq.setString("name", name);
    int result = ((Long) dbq.list().get(0)).intValue();
    if (result != 0) return true;
View Full Code Here

  public Date getSecurityGroupJoinDateForIdentity(SecurityGroup secGroup, Identity identity){
    String query = "select creationDate from " + "  org.olat.basesecurity.SecurityGroupMembershipImpl as sgi "
        + " where sgi.securityGroup = :secGroup and sgi.identity = :identId";
   
    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
    dbq.setLong("identId", identity.getKey().longValue());
    dbq.setLong("secGroup", secGroup.getKey());
    List result = dbq.list();
    if (result.size()==0){
      return null;
View Full Code Here

   * @see org.olat.basesecurity.Manager#countIdentitiesOfSecurityGroup(org.olat.basesecurity.SecurityGroup)
   */
  public int countIdentitiesOfSecurityGroup(SecurityGroup secGroup) {
    DB db = DBFactory.getInstance();
    String q = "select count(sgm) from org.olat.basesecurity.SecurityGroupMembershipImpl sgm where sgm.securityGroup = :group";
    DBQuery query = db.createQuery(q);
    query.setEntity("group", secGroup);
    int result = ((Long) query.list().get(0)).intValue();
    return result;
  }

View Full Code Here

    }
     
    // create query object now from string
    String query = sb.toString();
    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
   
    // add user attributes
    if (login != null)
      dbq.setString("login", login);
View Full Code Here

  public List<BusinessGroup> getGroupsOfBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    DBQuery query;
    if (bgContext == null) {
      String q = "select bg from org.olat.group.BusinessGroupImpl bg where bg.groupContext is null";
      query = db.createQuery(q);
    } else {
      String q = "select bg from org.olat.group.BusinessGroupImpl bg where bg.groupContext = :context";
      query = db.createQuery(q);
      query.setEntity("context", bgContext);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.