Java 类org.hibernate.type.TimestampType 实例源码
项目:lams
文件:VoteUsrAttemptDAO.java
@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();
}
项目:FinanceAnalytics
文件:PersistentInstant.java
@SuppressWarnings("deprecation")
public Object nullSafeGet(ResultSet resultSet, String name) throws SQLException {
java.sql.Timestamp value = (java.sql.Timestamp) (new TimestampType()).nullSafeGet(resultSet, name);
if (value == null) {
return null;
}
return DbDateUtils.fromSqlTimestamp(value);
}
项目:FinanceAnalytics
文件:PersistentInstant.java
@SuppressWarnings("deprecation")
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
if (value == null) {
s_logger.debug("INSTANT -> TIMESTAMP : NULL -> NULL");
(new TimestampType()).nullSafeSet(preparedStatement, null, index);
} else {
s_logger.debug("INSTANT -> TIMESTAMP : {} -> {}", value, DbDateUtils.toSqlTimestamp((Instant) value));
(new TimestampType()).nullSafeSet(preparedStatement, DbDateUtils.toSqlTimestamp((Instant) value), index);
}
}
项目:lams
文件:PeerreviewUserDAOHibernate.java
@Override
@SuppressWarnings("unchecked")
/**
* Will return List<[user.user_id, user.first_name, user.last_name, notebook entry, notebook date]>
*/
public List<Object[]> getUserNotebookEntriesForTablesorter(final Long toolSessionId, int page, int size, int sorting,
String searchString, ICoreNotebookService coreNotebookService) {
String sortingOrder;
switch (sorting) {
case PeerreviewConstants.SORT_BY_USERNAME_ASC:
sortingOrder = " ORDER BY user.first_name ASC";
break;
case PeerreviewConstants.SORT_BY_USERNAME_DESC:
sortingOrder = " ORDER BY user.first_name DESC";
break;
case PeerreviewConstants.SORT_BY_NOTEBOOK_ENTRY_ASC:
sortingOrder = " ORDER BY notebookEntry ASC";
break;
case PeerreviewConstants.SORT_BY_NOTEBOOK_ENTRY_DESC:
sortingOrder = " ORDER BY notebookEntry DESC";
break;
case PeerreviewConstants.SORT_BY_NO:
default:
sortingOrder = " ORDER BY user.user_id";
}
String[] notebookEntryStrings = coreNotebookService.getNotebookEntrySQLStrings(toolSessionId.toString(),
PeerreviewConstants.TOOL_SIGNATURE, "user.user_id", true);
// Basic select for the user records
StringBuilder queryText = new StringBuilder();
queryText.append("SELECT user.user_id, user.first_name, user.last_name ")
.append(notebookEntryStrings[0])
.append(" FROM tl_laprev11_user user ")
.append(" JOIN tl_laprev11_session session ON session.session_id = :toolSessionId AND user.session_uid = session.uid");
queryText.append(notebookEntryStrings[1]);
buildNameSearch(searchString, queryText, false);
// Now specify the sort based on the switch statement above.
queryText.append(sortingOrder);
SQLQuery query = getSession().createSQLQuery(queryText.toString());
query.addScalar("user_id", IntegerType.INSTANCE)
.addScalar("first_name", StringType.INSTANCE)
.addScalar("last_name", StringType.INSTANCE)
.addScalar("notebookEntry", StringType.INSTANCE)
.addScalar("notebookModifiedDate", TimestampType.INSTANCE)
.setLong("toolSessionId", toolSessionId.longValue())
.setFirstResult(page * size).setMaxResults(size);
return query.list();
}
项目:lams
文件:VoteUsrAttemptDAO.java
@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();
}
项目:lams
文件:NotebookUserDAO.java
@Override
@SuppressWarnings("unchecked")
/**
* Will return List<[NotebookUser, String, Date]> where the String is the notebook entry and the modified date.
*/
public List<Object[]> getUsersForTablesorter(final Long sessionId, int page, int size, int sorting,
String searchString, ICoreNotebookService coreNotebookService, IUserManagementService userManagementService) {
String sortingOrder;
switch (sorting) {
case NotebookConstants.SORT_BY_USERNAME_ASC:
sortingOrder = "user.last_name ASC, user.first_name ASC";
break;
case NotebookConstants.SORT_BY_USERNAME_DESC:
sortingOrder = "user.last_name DESC, user.first_name DESC";
break;
case NotebookConstants.SORT_BY_DATE_ASC:
sortingOrder = "notebookModifiedDate ASC";
break;
case NotebookConstants.SORT_BY_DATE_DESC:
sortingOrder = "notebookModifiedDate DESC";
break;
case NotebookConstants.SORT_BY_COMMENT_ASC:
sortingOrder = "user.teachers_comment ASC";
break;
case NotebookConstants.SORT_BY_COMMENT_DESC:
sortingOrder = "user.teachers_comment DESC";
break;
default:
sortingOrder = "user.last_name, user.first_name";
}
String[] notebookEntryStrings = coreNotebookService.getNotebookEntrySQLStrings(sessionId.toString(),
NotebookConstants.TOOL_SIGNATURE, "user.user_id", true);
String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id");
// Basic select for the user records
StringBuilder queryText = new StringBuilder();
queryText.append("SELECT user.* ");
queryText.append(notebookEntryStrings[0]);
queryText.append(portraitStrings[0]);
queryText.append(" FROM tl_lantbk11_user user ");
queryText.append(
" JOIN tl_lantbk11_session session ON user.notebook_session_uid = session.uid and session.session_id = :sessionId");
queryText.append(notebookEntryStrings[1]);
queryText.append(portraitStrings[1]);
// If filtering by name add a name based where clause
buildNameSearch(searchString, queryText);
// Now specify the sort based on the switch statement above.
queryText.append(" ORDER BY " + sortingOrder);
SQLQuery query = getSession().createSQLQuery(queryText.toString());
query.addEntity("user", NotebookUser.class).addScalar("notebookEntry", StringType.INSTANCE)
.addScalar("notebookModifiedDate", TimestampType.INSTANCE).addScalar("portraitId", IntegerType.INSTANCE)
.setLong("sessionId", sessionId.longValue())
.setFirstResult(page * size).setMaxResults(size);
return query.list();
}
项目:jadira
文件:AbstractTimestampColumnMapper.java
@Override
public final TimestampType getHibernateType() {
return TimestampType.INSTANCE;
}