本文整理匯總了Java中org.hibernate.type.StringType類的典型用法代碼示例。如果您正苦於以下問題:Java StringType類的具體用法?Java StringType怎麽用?Java StringType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StringType類屬於org.hibernate.type包,在下文中一共展示了StringType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getStatisticsBySession
import org.hibernate.type.StringType; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public List<VoteStatsDTO> getStatisticsBySession(Long toolContentId) {
SQLQuery query = getSession().createSQLQuery(GET_STATISTICS);
query.addScalar("sessionUid", LongType.INSTANCE).addScalar("sessionName", StringType.INSTANCE)
.addScalar("countUsersComplete", IntegerType.INSTANCE).setLong("contentId", toolContentId)
.setResultTransformer(Transformers.aliasToBean(VoteStatsDTO.class));
return query.list();
}
示例2: findAuthoredStatsForStudentByForumId
import org.hibernate.type.StringType; //導入依賴的package包/類
public List<UserStatistics> findAuthoredStatsForStudentByForumId(final String studentId, final Long topicId) {
if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByForumId()");
HibernateCallback<List<Object[]>> hcb = session -> {
Query q = session.getNamedQuery("findAuthoredStatsForStudentByForumId");
q.setParameter("forumId", topicId, LongType.INSTANCE);
q.setParameter("userId", studentId, StringType.INSTANCE);
return q.list();
};
List<UserStatistics> returnList = new ArrayList<UserStatistics>();
List<Object[]> results = getHibernateTemplate().execute(hcb);
for(Object[] result : results){
UserStatistics stat = new UserStatistics((String) result[0], (String) result[1], (Date) result[2], (String) result[3],
((Integer) result[4]).toString(), ((Integer) result[5]).toString(), ((Integer) result[6]).toString(), studentId);
returnList.add(stat);
}
return returnList;
}
示例3: get
import org.hibernate.type.StringType; //導入依賴的package包/類
protected Object get(Class clazz, String id) {
if (clazz.equals(String.class) || clazz.equals(StringType.class)) return id;
if (clazz.equals(Character.class) || clazz.equals(CharacterType.class)) return (id == null || id.isEmpty() ? null : id.charAt(0));
if (clazz.equals(Byte.class) || clazz.equals(ByteType.class)) return Byte.valueOf(id);
if (clazz.equals(Short.class) || clazz.equals(ShortType.class)) return Short.valueOf(id);
if (clazz.equals(Integer.class) || clazz.equals(IntegerType.class)) return Integer.valueOf(id);
if (clazz.equals(Long.class) || clazz.equals(LongType.class)) return Long.valueOf(id);
if (clazz.equals(Float.class) || clazz.equals(FloatType.class)) return Float.valueOf(id);
if (clazz.equals(Double.class) || clazz.equals(DoubleType.class)) return Double.valueOf(id);
if (clazz.equals(Boolean.class) || clazz.equals(BooleanType.class)) return Boolean.valueOf(id);
Map<String, Entity> entities = iEntities.get(clazz.getName());
if (entities != null) {
Entity entity = entities.get(id);
if (entity != null) return entity.getObject();
}
for (Map.Entry<String, Map<String, Entity>> entry: iEntities.entrySet()) {
Entity o = entry.getValue().get(id);
if (o != null && clazz.isInstance(o.getObject())) return o.getObject();
}
if (clazz.equals(Session.class))
return ((Entity)iEntities.get(Session.class.getName()).values().iterator().next()).getObject();
if (clazz.equals(Student.class))
return checkUnknown(clazz, id, iStudents.get(id));
if (iIsClone)
return checkUnknown(clazz, id,
iHibSession.get(clazz, clazz.equals(ItypeDesc.class) ? (Serializable) Integer.valueOf(id) : (Serializable) Long.valueOf(id)));
return checkUnknown(clazz, id, null);
}
示例4: testConfiguration
import org.hibernate.type.StringType; //導入依賴的package包/類
/**
* Check strategy configuration.
*/
@Test
public void testConfiguration() {
final Properties params = new Properties();
params.put("identity_tables", "summy.seg");
params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, new ObjectNameNormalizer() {
@Override
protected MetadataBuildingContext getBuildingContext() {
return null;
}
});
OptimizedSequenceStyleGenerator optimizedSequenceStyleGenerator = newStyleGenerator();
optimizedSequenceStyleGenerator.configure(StringType.INSTANCE, params, newServiceRegistry());
}
示例5: cleanUpRows
import org.hibernate.type.StringType; //導入依賴的package包/類
private void cleanUpRows(SharedSessionContractImplementor session, Queryable persister) {
final String sql = "delete from " + fullyQualifiedTableName + " where " + discriminatorColumn + "=?";
PreparedStatement ps = null;
try {
ps = session.getJdbcCoordinator().getStatementPreparer().prepareStatement(sql, false);
ps.setString(1, generateDiscriminatorValue(persister));
StringType.INSTANCE.set(ps, generateDiscriminatorValue(persister), 1, session);
session.getJdbcCoordinator().getResultSetReturn().executeUpdate(ps);
} catch (SQLException e) {
throw session.getJdbcServices().getSqlExceptionHelper().convert(e, "Unable to clean up id table [" + fullyQualifiedTableName + "]", sql);
} finally {
if (ps != null) {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release(ps);
}
}
}
開發者ID:grimsa,項目名稱:hibernate-single-table-bulk-id-strategy,代碼行數:17,代碼來源:SingleGlobalTemporaryTableBulkIdStrategy.java
示例6: getPageIds
import org.hibernate.type.StringType; //導入依賴的package包/類
/**
* Gets the page ids for a given title.<br>
*
*
* @param title The title of the page.
* @return The id for the page with the given title.
* @throws WikiApiException
*/
public List<Integer> getPageIds(String title) throws WikiApiException {
Session session = this.__getHibernateSession();
session.beginTransaction();
Iterator results = session.createQuery(
"select p.pageID from PageMapLine as p where p.name = :pName").setParameter("pName", title, StringType.INSTANCE).list().iterator();
session.getTransaction().commit();
if(!results.hasNext()){
throw new WikiPageNotFoundException();
}
List<Integer> resultList = new LinkedList<Integer>();
while(results.hasNext()){
resultList.add((Integer)results.next());
}
return resultList;
}
示例7: getSyllabusItemByContextId
import org.hibernate.type.StringType; //導入依賴的package包/類
/**
* getSyllabusItemByContextId finds a SyllabusItem
* @param contextId
* @return SyllabusItem
*
*/
public SyllabusItem getSyllabusItemByContextId(final String contextId)
{
if (contextId == null)
{
throw new IllegalArgumentException("Null Argument");
}
HibernateCallback<SyllabusItem> hcb = session -> {
Query q = session.getNamedQuery(QUERY_BY_CONTEXTID);
q.setParameter(CONTEXT_ID, contextId, StringType.INSTANCE);
return (SyllabusItem) q.uniqueResult();
};
return getHibernateTemplate().execute(hcb);
}
示例8: createCategory
import org.hibernate.type.StringType; //導入依賴的package包/類
/**
* @see de.tudarmstadt.ukp.wikipedia.api.Category#Category(Wikipedia, String)
*/
private void createCategory(Title title) throws WikiPageNotFoundException {
String name = title.getWikiStyleTitle();
Session session = this.wiki.__getHibernateSession();
session.beginTransaction();
Object returnValue;
returnValue = session.createNativeQuery(
"select cat.pageId from Category as cat where cat.name = :name COLLATE utf8_bin")
.setParameter("name", name, StringType.INSTANCE)
.uniqueResult();
session.getTransaction().commit();
// if there is no category with this name, the hibernateCategory is null
if (returnValue == null) {
hibernateCategory = null;
throw new WikiPageNotFoundException("No category with name " + name + " was found.");
}
else {
// now cast it into an integer
int pageID = (Integer) returnValue;
createCategory( pageID);
}
}
示例9: getEntityId
import org.hibernate.type.StringType; //導入依賴的package包/類
protected String getEntityId(Object entity, TranslatedEntity entityType) {
Map<String, Object> idMetadata = dao.getIdPropertyMetadata(entityType);
String idProperty = (String) idMetadata.get("name");
Type idType = (Type) idMetadata.get("type");
if (!(idType instanceof LongType || idType instanceof StringType)) {
throw new UnsupportedOperationException("Only ID types of String and Long are currently supported");
}
Object idValue = null;
try {
idValue = PropertyUtils.getProperty(entity, idProperty);
} catch (Exception e) {
throw new RuntimeException("Error reading id property", e);
}
if (idType instanceof StringType) {
return (String) idValue;
} else if (idType instanceof LongType) {
return String.valueOf(idValue);
}
throw new IllegalArgumentException(String.format("Could not retrieve value for id property. Object: [%s], " +
"ID Property: [%s], ID Type: [%s]", entity, idProperty, idType));
}
示例10: getLinks
import org.hibernate.type.StringType; //導入依賴的package包/類
public List<Link> getLinks(final String activityRef, final boolean any,
final String context) {
if ((activityRef == null) || (context == null)) {
throw new IllegalArgumentException(NULL_ARG);
}
return getHibernateTemplate().execute((HibernateCallback<List<Link>>) session -> {
String likeContext = "%/"+context+"/%";
Query q = session.getNamedQuery(QUERY_LINKS_BY_ACTIVITY_CONTEXT);
if (!any) {
q = session.getNamedQuery(QUERY_LINKS_BY_ACTIVITY_CONTEXT_VISIBLE);
q.setParameter(VISIBLE, true);
}
q.setParameter(ACTIVITY_REF, activityRef, StringType.INSTANCE);
q.setParameter(CONTEXT, likeContext, StringType.INSTANCE);
return q.list();
});
}
示例11: listSakaiPersons
import org.hibernate.type.StringType; //導入依賴的package包/類
private List<SakaiPerson> listSakaiPersons(final Collection<String> userIds, final Type recordType)
{
final HibernateCallback hcb = new HibernateCallback()
{
public Object doInHibernate(Session session) throws HibernateException
{
Query q = session.getNamedQuery(HQL_FIND_SAKAI_PERSONS_BY_AGENTS_AND_TYPE);
q.setParameterList(AGENT_UUID_COLLECTION, userIds);
q.setParameter(TYPE_UUID, recordType.getUuid(), StringType.INSTANCE);
// q.setCacheable(false);
return q.list();
}
};
List hb = (List) getHibernateTemplate().execute(hcb);
if (photoService.overRidesDefault()) {
return getDiskPhotosForList(hb);
} else {
return hb;
}
}
示例12: fetchAssignmentsToConvert
import org.hibernate.type.StringType; //導入依賴的package包/類
@Override
@Transactional(readOnly = true)
public List<String> fetchAssignmentsToConvert() {
List<String> list;
try {
list = sessionFactory.getCurrentSession()
.createSQLQuery("SELECT ASSIGNMENT_ID FROM ASSIGNMENT_ASSIGNMENT")
.addScalar("ASSIGNMENT_ID", StringType.INSTANCE)
.list();
return list;
} catch (Exception e) {
log.warn("could not query table ASSIGNMENT_ASSIGNMENT for assignments to migrate, {}", e.getMessage());
}
return Collections.emptyList();
}
示例13: fetchAssignment
import org.hibernate.type.StringType; //導入依賴的package包/類
@Override
@Transactional(readOnly = true)
public String fetchAssignment(String assignmentId) {
try {
String xml = (String) sessionFactory.getCurrentSession()
.createSQLQuery("SELECT XML FROM ASSIGNMENT_ASSIGNMENT WHERE ASSIGNMENT_ID = :id")
.addScalar("XML", StringType.INSTANCE)
.setParameter("id", assignmentId, StringType.INSTANCE)
.uniqueResult();
return xml;
} catch (Exception e) {
log.warn("could not query table ASSIGNMENT_ASSIGNMENT for assignment {}, {}", assignmentId, e.getMessage());
}
return null;
}
示例14: fetchAssignmentSubmissions
import org.hibernate.type.StringType; //導入依賴的package包/類
@Override
@Transactional(readOnly = true)
public List<String> fetchAssignmentSubmissions(String assignmentId) {
try {
List<String> list = sessionFactory.getCurrentSession()
.createSQLQuery("SELECT XML FROM ASSIGNMENT_SUBMISSION WHERE CONTEXT = :id")
.addScalar("XML", StringType.INSTANCE)
.setParameter("id", assignmentId, StringType.INSTANCE)
.list();
return list;
} catch (Exception e) {
log.warn("could not query table ASSIGNMENT_SUBMISSION for submissions to migrate, {}", e.getMessage());
}
return Collections.emptyList();
}
示例15: getRequestedConnectionUserIdsForUser
import org.hibernate.type.StringType; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public List<String> getRequestedConnectionUserIdsForUser(final String userId) {
//get friends of this user [and map it automatically to the Friend object]
//updated: now just returns a List of Strings
HibernateCallback<List<String>> hcb = session -> {
Query q = session.getNamedQuery(QUERY_GET_FRIEND_REQUESTS_FOR_USER);
q.setParameter(USER_UUID, userId, StringType.INSTANCE);
q.setBoolean("false", Boolean.FALSE);
//q.setResultTransformer(Transformers.aliasToBean(Friend.class));
return q.list();
};
return getHibernateTemplate().execute(hcb);
}