当前位置: 首页>>代码示例>>Java>>正文


Java SQLQuery.setLong方法代码示例

本文整理汇总了Java中org.hibernate.SQLQuery.setLong方法的典型用法代码示例。如果您正苦于以下问题:Java SQLQuery.setLong方法的具体用法?Java SQLQuery.setLong怎么用?Java SQLQuery.setLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.SQLQuery的用法示例。


在下文中一共展示了SQLQuery.setLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteHoldingExtras

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
protected void deleteHoldingExtras(Session session, long itemId)
{
	SQLQuery sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %h_authors where %h_id in (select id from %h where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
	sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %h_ids where %h_id in (select id from %h where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:AbstractCopyrightDao.java

示例2: delete

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   public void delete(Object object) {
// remove references to the removed page
WikiPage removedWikiPage = (WikiPage) object;
String title = removedWikiPage.getTitle();
String escapedTitle = WikiPageDTO.javaScriptEscape(title);
String codeToReplace = WikiPageDAO.CHANGE_WIKI_JAVASCRIPT_METHOD.replace("?", escapedTitle);
String replacementCode = "#";

SQLQuery query = getSessionFactory().getCurrentSession().createSQLQuery(REMOVE_WIKI_REFERENCES);
query.setString(0, codeToReplace);
query.setString(1, replacementCode);
query.setLong(2, removedWikiPage.getParentWiki().getUid());

super.delete(object);
query.executeUpdate();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:WikiPageDAO.java

示例3: deletePortionExtras

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
protected void deletePortionExtras(Session session, long itemId)
{
	SQLQuery sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %p_authors where %p_id in (select id from %p where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
	sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %p_topics where %p_id in (select id from %p where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:AbstractCopyrightDao.java

示例4: getRawLeaderMarksByToolContentId

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   @Override
   public List<Number> getRawLeaderMarksByToolContentId(Long toolContentId) {

SQLQuery query = getSession().createSQLQuery(LOAD_MARKS_FOR_LEADERS);
query.setLong("toolContentId", toolContentId);
List<Number> list = query.list();
return list;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AssessmentUserDAOHibernate.java

示例5: getFirstTotalScoresByContentId

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   public List<AssessmentUserDTO> getFirstTotalScoresByContentId(Long toolContentId) {
final String FIRST_SCORES_BY_CONTENT_ID = "SELECT user.user_id, res.grade "
	+ "FROM tl_laasse10_assessment_result AS res "
	+ "JOIN tl_laasse10_user AS user ON res.user_uid = user.uid "
	+ "JOIN tl_laasse10_assessment AS assess ON res.assessment_uid = assess.uid AND assess.content_id = :contentId "
	+ "INNER JOIN (SELECT user_uid, MIN(start_date) AS startDate FROM tl_laasse10_assessment_result WHERE finish_date IS NOT NULL GROUP BY user_uid) firstRes "
	+ "ON (res.user_uid = firstRes.user_uid AND res.start_date = firstRes.startDate) GROUP BY res.user_uid";

SQLQuery query = getSession().createSQLQuery(FIRST_SCORES_BY_CONTENT_ID);
query.setLong("contentId", toolContentId);
List<Object[]> list = query.list();
return convertResultsToAssessmentUserDTOList(list);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AssessmentResultDAOHibernate.java

示例6: getUserAttemptsForTablesorter

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   @SuppressWarnings("unchecked")
   /**
    * Gets the basic details about an attempt for a nomination. questionUid must not be null, sessionUid may be NULL.
    * This is
    * unusual for these methods - usually sessionId may not be null. In this case if sessionUid is null then you get
    * the values for the whole class, not just the group.
    *
    * Will return List<[login (String), fullname(String), attemptTime(Timestamp]>
    */
   public List<Object[]> getUserAttemptsForTablesorter(Long sessionUid, Long questionUid, int page, int size,
    int sorting, String searchString, IUserManagementService userManagementService) {
String sortingOrder;
switch (sorting) {
    case VoteAppConstants.SORT_BY_NAME_ASC:
	sortingOrder = "user.fullname ASC";
	break;
    case VoteAppConstants.SORT_BY_NAME_DESC:
	sortingOrder = "user.fullname DESC";
	break;
    case VoteAppConstants.SORT_BY_DATE_ASC:
	sortingOrder = "attempt.attempt_time ASC";
	break;
    case VoteAppConstants.SORT_BY_DATE_DESC:
	sortingOrder = "attempt.attempt_time DESC";
	break;
    default:
	sortingOrder = "user.uid";
}

String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id");

// Basic select for the user records
StringBuilder queryText = new StringBuilder(FIND_USER_ANSWERS_BY_QUESTION_UID_SELECT)
	.append(portraitStrings[0])
	.append(FIND_USER_ANSWERS_BY_QUESTION_UID_FROM)
	.append(portraitStrings[1]);

if (sessionUid != null) {
    queryText.append(FIND_USER_ANSWERS_BY_QUESTION_UID_SESSION_ADDITION);
}

// If filtering by name add a name based where clause
buildNameSearch(searchString, queryText, true);

// Now specify the sort based on the switch statement above.
queryText.append(" ORDER BY " + sortingOrder);

SQLQuery query = getSession().createSQLQuery(queryText.toString());
query.addScalar("user_id", IntegerType.INSTANCE).addScalar("username", StringType.INSTANCE)
	.addScalar("fullname", StringType.INSTANCE)
	.addScalar("attemptTime", TimestampType.INSTANCE)
	.addScalar("portraitId", IntegerType.INSTANCE)
	.setLong("questionUid", questionUid.longValue())
	.setFirstResult(page * size).setMaxResults(size);
if (sessionUid != null) {
    query.setLong("sessionUid", sessionUid.longValue());
}

return query.list();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:62,代码来源:VoteUsrAttemptDAO.java

示例7: getCountUsersForOpenTextEntries

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   @SuppressWarnings("rawtypes")
   public int getCountUsersForOpenTextEntries(Long sessionUid, Long toolContentId, String searchStringVote,
    String searchStringUsername) {

SQLQuery query;
StringBuilder queryText = new StringBuilder(COUNT_USERS_OPEN_TEXT_BY_SESSION_UID);

if (sessionUid != null) {
    // get all the users who did an open text reply, restricting by session
    queryText.append(FIND_USER_OPEN_TEXT_SESSION_UID_ADD);
    buildCombinedSearch(searchStringVote, searchStringUsername, queryText);
    query = getSession().createSQLQuery(queryText.toString());
    query.setLong("sessionUid", sessionUid);

} else {

    // get all the users for this content (more than one session potentially)
    queryText.append(FIND_USER_OPEN_TEXT_CONTENT_UID_ADD);
    buildCombinedSearch(searchStringVote, searchStringUsername, queryText);
    query = getSession().createSQLQuery(queryText.toString());
    query.setLong("toolContentId", toolContentId);

}

List list = query.list();
if (list == null || list.size() == 0) {
    return 0;
}
return ((Number) list.get(0)).intValue();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:VoteUsrAttemptDAO.java

示例8: getUsersWithPortraitsBySessionID

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   @SuppressWarnings("unchecked")
   public List<Object[]> getUsersWithPortraitsBySessionID(Long sessionId) {
final String LOAD_USERS_WITH_PORTRAITS_BY_SESSION_ID = "SELECT user.user_id, luser.portrait_uuid portraitId FROM tl_lamc11_que_usr user  " +
	" INNER JOIN tl_lamc11_session session ON user.mc_session_id=session.uid" +
	" INNER JOIN lams_user luser ON luser.user_id = user.que_usr_id" +
	" WHERE session.mc_session_id = :sessionId";

SQLQuery query = getSession().createSQLQuery(LOAD_USERS_WITH_PORTRAITS_BY_SESSION_ID);
query.setLong("sessionId", sessionId);
List<Object[]> list = query.list();

ArrayList<Object[]> userDtos = new ArrayList<Object[]>();
if (list != null && list.size() > 0) {
    for (Object[] element : list) {

	Long userId = ((Number) element[0]).longValue();
	Long portraitId = element[1] == null ? null : ((Number) element[1]).longValue();

	Object[] userDto = new Object[2];
	userDto[0] = userId;
	userDto[0] = portraitId;
	userDtos.add(userDto);
    }

}

return userDtos;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:McUserDAO.java

示例9: getRawUserMarksBySession

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   @Override
   public List<Number> getRawUserMarksBySession(Long sessionId) {

SQLQuery query = getSession().createSQLQuery(LOAD_MARKS_FOR_SESSION);
query.setLong("sessionId", sessionId);
List<Number> list = query.list();
return list;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:McUserDAO.java

示例10: getCountUsersBySessionWithSearch

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   public int getCountUsersBySessionWithSearch(final Long toolSessionId, String searchString) {

StringBuilder queryText = new StringBuilder(GET_COUNT_USERS_FOR_SESSION_AND_QUESTION_WITH_NAME_SEARCH);
buildNameSearch(queryText, searchString);

SQLQuery query = getSession().createSQLQuery(queryText.toString());
query.setLong("toolSessionId", toolSessionId);
List list = query.list();

if (list == null || list.size() == 0) {
    return 0;
}
return ((Number) list.get(0)).intValue();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:QaQueUsrDAO.java

示例11: isLessonLearner

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   public boolean isLessonLearner(Long lessonId, Integer userId) {
SQLQuery query = getSession().createSQLQuery(SecurityDAO.CHECK_LESSON_LEARNER);
query.setLong(0, lessonId);
query.setInteger(1, userId);
return !query.list().isEmpty();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SecurityDAO.java

示例12: getPagedUsersBySession

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   @Override
   public List<AssessmentUserDTO> getPagedUsersBySession(Long sessionId, int page, int size, String sortBy,
    String sortOrder, String searchString, IUserManagementService userManagementService) {

String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id");

StringBuilder bldr = new StringBuilder(LOAD_USERS_ORDERED_BY_SESSION_SELECT)
	.append(portraitStrings[0])
	.append(LOAD_USERS_ORDERED_BY_SESSION_FROM)
	.append(portraitStrings[1])
	.append(LOAD_USERS_ORDERED_BY_SESSION_JOIN);
if ( "total".equalsIgnoreCase(sortBy) )
    bldr.append(LOAD_USERS_ORDERED_ORDER_BY_TOTAL);
else
    bldr.append(LOAD_USERS_ORDERED_ORDER_BY_NAME);
bldr.append(sortOrder);

SQLQuery query = getSession().createSQLQuery(bldr.toString());
query.setLong("sessionId", sessionId);
// support for custom search from a toolbar
searchString = searchString == null ? "" : searchString;
query.setString("searchString", searchString);
query.setFirstResult(page * size);
query.setMaxResults(size);
List<Object[]> list = query.list();

ArrayList<AssessmentUserDTO> userDtos = new ArrayList<AssessmentUserDTO>();
if (list != null && list.size() > 0) {
    for (Object[] element : list) {

	Long userId = ((Number) element[0]).longValue();
	String firstName = (String) element[1];
	String lastName = (String) element[2];
	String login = (String) element[3];
	float grade = element[4] == null ? 0 : ((Number) element[4]).floatValue();
	Long portraitId = element[5] == null ? null : ((Number) element[5]).longValue();

	AssessmentUserDTO userDto = new AssessmentUserDTO();
	userDto.setUserId(userId);
	userDto.setFirstName(firstName);
	userDto.setLastName(lastName);
	userDto.setLogin(login);
	userDto.setGrade(grade);
	userDto.setPortraitId(portraitId);
	userDtos.add(userDto);
    }

}

return userDtos;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:53,代码来源:AssessmentUserDAOHibernate.java

示例13: getPagedUsersBySessionAndQuestion

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   @Override
   public List<AssessmentUserDTO> getPagedUsersBySessionAndQuestion(Long sessionId, Long questionUid, int page,
    int size, String sortBy, String sortOrder, String searchString, IUserManagementService userManagementService) {

String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id");

StringBuilder bldr = new StringBuilder(LOAD_USERS_ORDERED_BY_SESSION_QUESTION_SELECT)
	.append(portraitStrings[0])
	.append(LOAD_USERS_ORDERED_BY_SESSION_QUESTION_FROM)
	.append(portraitStrings[1])
	.append(LOAD_USERS_ORDERED_BY_SESSION_QUESTION_JOIN);
if ( "grade".equalsIgnoreCase(sortBy) )
    bldr.append(LOAD_USERS_ORDERED_ORDER_BY_RESULT);
else
    bldr.append(LOAD_USERS_ORDERED_ORDER_BY_NAME);
bldr.append(sortOrder);

SQLQuery query = getSession().createSQLQuery(bldr.toString());
query.setLong("sessionId", sessionId);
query.setLong("questionUid", questionUid);
// support for custom search from a toolbar
searchString = searchString == null ? "" : searchString;
query.setString("searchString", searchString);
query.setFirstResult(page * size);
query.setMaxResults(size);
List<Object[]> list = query.list();

ArrayList<AssessmentUserDTO> userDtos = new ArrayList<AssessmentUserDTO>();
if (list != null && list.size() > 0) {
    for (Object[] element : list) {

	Long questionResultUid = ((Number) element[0]).longValue();
	String firstName = (String) element[1];
	String lastName = (String) element[2];
	String login = (String) element[3];
	float grade = element[4] == null ? 0 : ((Number) element[4]).floatValue();
	Long portraitId  = element[5] == null ? null : ((Number) element[5]).longValue();

	AssessmentUserDTO userDto = new AssessmentUserDTO();
	userDto.setQuestionResultUid(questionResultUid);
	;
	userDto.setFirstName(firstName);
	userDto.setLastName(lastName);
	userDto.setLogin(login);
	userDto.setGrade(grade);
	userDto.setPortraitId(portraitId);
	userDtos.add(userDto);
    }

}

return userDtos;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:55,代码来源:AssessmentUserDAOHibernate.java

示例14: getUserOpenTextAttemptsForTablesorter

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   @SuppressWarnings("unchecked")
   /**
    * Gets the details about an open text entry. Either sessionUid or toolContentId must be supplied - if sessionUid is
    * supplied
    * then it will be restricted to that session. Due to the large number of fields needed, a DTO will be returned.
    *
    * Will return List<OpenTextAnswerDTO>
    */
   public List<OpenTextAnswerDTO> getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long toolContentId, int page,
    int size, int sorting, String searchStringVote, String searchStringUsername, IUserManagementService userManagementService) {
String sortingOrder;
switch (sorting) {
    case VoteAppConstants.SORT_BY_NAME_ASC:
	sortingOrder = "user.fullname ASC";
	break;
    case VoteAppConstants.SORT_BY_NAME_DESC:
	sortingOrder = "user.fullname DESC";
	break;
    case VoteAppConstants.SORT_BY_DATE_ASC:
	sortingOrder = "attempt.attempt_time ASC";
	break;
    case VoteAppConstants.SORT_BY_DATE_DESC:
	sortingOrder = "attempt.attempt_time DESC";
	break;
    case VoteAppConstants.SORT_BY_ENTRY_ASC:
	sortingOrder = "attempt.userEntry ASC";
	break;
    case VoteAppConstants.SORT_BY_ENTRY_DESC:
	sortingOrder = "attempt.userEntry DESC";
	break;
    case VoteAppConstants.SORT_BY_VISIBLE_ASC:
	sortingOrder = "attempt.visible ASC";
	break;
    case VoteAppConstants.SORT_BY_VISIBLE_DESC:
	sortingOrder = "attempt.visible DESC";
	break;
    default:
	sortingOrder = "user.uid";
}

String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id");

// Basic select for the user records
StringBuilder queryText = new StringBuilder(FIND_USER_OPEN_TEXT_SELECT)
	.append(portraitStrings[0])
	.append(FIND_USER_OPEN_TEXT_FROM);

if (sessionUid != null) {
    queryText.append(FIND_USER_OPEN_TEXT_SESSION_UID_ADD);
} else {
    queryText.append(FIND_USER_OPEN_TEXT_CONTENT_UID_ADD);
}
queryText.append(portraitStrings[1]);

// If filtering by name/entry add a where clause
buildCombinedSearch(searchStringVote, searchStringUsername, queryText);

// Now specify the sort based on the switch statement above.
queryText.append(" ORDER BY " + sortingOrder);

SQLQuery query = getSession().createSQLQuery(queryText.toString());
query.addScalar("userUid", LongType.INSTANCE).addScalar("login", StringType.INSTANCE)
	.addScalar("fullName", StringType.INSTANCE).addScalar("userEntryUid", LongType.INSTANCE)
	.addScalar("userEntry", StringType.INSTANCE).addScalar("attemptTime", TimestampType.INSTANCE)
	.addScalar("visible", BooleanType.INSTANCE).addScalar("portraitId", LongType.INSTANCE)
	.setFirstResult(page * size).setMaxResults(size)
	.setResultTransformer(Transformers.aliasToBean(OpenTextAnswerDTO.class));

if (sessionUid != null) {
    query.setLong("sessionUid", sessionUid);
} else {
    query.setLong("toolContentId", toolContentId);
}

return query.list();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:78,代码来源:VoteUsrAttemptDAO.java

示例15: getPagedUsersBySession

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   @Override
   public List<McUserMarkDTO> getPagedUsersBySession(Long sessionId, int page, int size, String sortBy,
    String sortOrder, String searchString, IUserManagementService userManagementService) {

String[] portraitStrings = userManagementService.getPortraitSQL("user.que_usr_id");

StringBuilder bldr = new StringBuilder(LOAD_USERS_SELECT)
	.append(portraitStrings[0])
	.append(LOAD_USERS_FROM)
	.append(portraitStrings[1])
	.append(LOAD_USERS_JOINWHERE)
	.append(sortOrder);

SQLQuery query = getSession().createSQLQuery(bldr.toString());
query.setLong("sessionId", sessionId);
// support for custom search from a toolbar
searchString = searchString == null ? "" : searchString;
query.setString("searchString", searchString);
query.setString("sortBy", sortBy);
query.setFirstResult(page * size);
query.setMaxResults(size);
List<Object[]> list = query.list();

ArrayList<McUserMarkDTO> userDtos = new ArrayList<McUserMarkDTO>();
if (list != null && list.size() > 0) {
    for (Object[] element : list) {

	Long userUid = ((Number) element[0]).longValue();
	Long userId = ((Number) element[1]).longValue();
	String fullName = (String) element[2];
	Integer totalMark = element[3] == null ? 0 : ((Number) element[3]).intValue();
	Long portraitId = element[4] == null ? null : ((Number) element[4]).longValue();

	McUserMarkDTO userDto = new McUserMarkDTO();
	userDto.setQueUsrId(userUid.toString());
	userDto.setUserId(userId.toString());
	userDto.setFullName(fullName);
	userDto.setTotalMark(new Long(totalMark));
	userDto.setPortraitId(portraitId==null ? null : portraitId.toString());
	userDtos.add(userDto);
    }

}

return userDtos;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:McUserDAO.java


注:本文中的org.hibernate.SQLQuery.setLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。