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


Java LongType类代码示例

本文整理汇总了Java中org.hibernate.type.LongType的典型用法代码示例。如果您正苦于以下问题:Java LongType类的具体用法?Java LongType怎么用?Java LongType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getStatisticsBySession

import org.hibernate.type.LongType; //导入依赖的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();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:VoteUsrAttemptDAO.java

示例2: findReadStatsForStudentByForumId

import org.hibernate.type.LongType; //导入依赖的package包/类
public List<UserStatistics> findReadStatsForStudentByForumId(final String studentId, final Long forumId) {
	if (log.isDebugEnabled()) log.debug("findReadStatsForStudentByForumId()");

	HibernateCallback<List<Object[]>> hcb = session -> {
        Query q = session.getNamedQuery("findReadStatsForStudentByForumId");
        q.setParameter("userId", studentId, StringType.INSTANCE);
        q.setParameter("forumId", forumId, LongType.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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:MessageForumsMessageManagerImpl.java

示例3: findAuthoredStatsForStudentByForumId

import org.hibernate.type.LongType; //导入依赖的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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:MessageForumsMessageManagerImpl.java

示例4: getAssignments

import org.hibernate.type.LongType; //导入依赖的package包/类
public Collection<Assignment> getAssignments(Collection<Long> solutionId) {
	if (solutionId.isEmpty()) return getCommitedAssignments();
	List<Assignment> ret = new ArrayList<Assignment>(new LocationDAO().getSession().createQuery(
			"select a from Assignment a inner join a.rooms r where " +
			"r.uniqueId = :locationId and a.solution.uniqueId in (:solutionIds)")
			.setLong("locationId", getUniqueId())
			.setParameterList("solutionIds", solutionId, new LongType())
			.setCacheable(true).list());
	ret.addAll(new LocationDAO().getSession().createQuery(
			"select a from Assignment a inner join a.rooms r where " +
            "r.uniqueId = :locationId and a.solution.commited = true and " +
			"a.solution.owner.uniqueId not in (select s.owner.uniqueId from Solution s where s.uniqueId in (:solutionIds))")
			.setLong("locationId", getUniqueId())
			.setParameterList("solutionIds", solutionId, new LongType())
            .setCacheable(true).list());
	return ret;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:18,代码来源:Location.java

示例5: createModel

import org.hibernate.type.LongType; //导入依赖的package包/类
public static TimetableGridModel createModel(String solutionIdsStr, StudentGroupInfo g, org.hibernate.Session hibSession, TimetableGridContext context) {
  	TimetableGridModel model = new TimetableGridModel(ResourceType.STUDENT_GROUP.ordinal(), g.getGroupId());
  	model.setName(g.getGroupName());
  	model.setFirstDay(context.getFirstDay());
  	model.setFirstSessionDay(context.getFirstSessionDay());
  	model.setFirstDate(context.getFirstDate());

List<Long> classIds = new ArrayList<Long>();
for (StudentGroupInfo.ClassInfo clazz: g.getGroupAssignments())
	classIds.add(clazz.getClassId());
if (classIds.isEmpty()) return null;

Query q = hibSession.createQuery(
		"select distinct a from Assignment a where a.solution.uniqueId in ("+solutionIdsStr+") and a.classId in (:classIds)");
q.setParameterList("classIds", classIds, new LongType());
q.setCacheable(true);
List assignments = q.list();
model.setSize((int)Math.round(g.countStudentWeights()));

for (Iterator i = assignments.iterator(); i.hasNext(); ) {
	Assignment assignment = (Assignment)i.next();
	List<TimetableGridCell> cells = createCells(model, assignment, hibSession, context, false); 
	StudentGroupInfo.ClassInfo ci = g.getGroupAssignment(assignment.getClassId());
	if (ci != null) {
		int total = g.countStudentsOfOffering(assignment.getClazz().getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getUniqueId());
		for (TimetableGridCell cell: cells) {
			cell.setGroup("(" + Math.round(ci.countStudentsWeight()) + ")");
			if (ci.getStudents() != null && !ci.getStudents().isEmpty() && total > 1) {
				int assigned = ci.getStudents().size();
				int minLimit = assignment.getClazz().getExpectedCapacity();
               	int maxLimit = assignment.getClazz().getMaxExpectedCapacity();
               	int limit = maxLimit;
               	if (minLimit < maxLimit) {
               		int roomLimit = (int) Math.floor(assignment.getPlacement().getRoomSize() / (assignment.getClazz().getRoomRatio() == null ? 1.0f : assignment.getClazz().getRoomRatio()));
               		// int roomLimit = Math.round((c.getRoomRatio() == null ? 1.0f : c.getRoomRatio()) * p.getRoomSize());
               		limit = Math.min(Math.max(minLimit, roomLimit), maxLimit);
               	}
                   if (assignment.getClazz().getSchedulingSubpart().getInstrOfferingConfig().isUnlimitedEnrollment() || limit >= 9999) limit = Integer.MAX_VALUE;
				int p = 100 * assigned / Math.min(limit, total);
				cell.setBackground(percentage2color(p));
				cell.setPreference(assigned + " of " + total);
			}
		}
	}
}
model.setUtilization(g.getGroupValue());

return model;
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:50,代码来源:TimetableGridSolutionHelper.java

示例6: get

import org.hibernate.type.LongType; //导入依赖的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);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:30,代码来源:SessionRestore.java

示例7: getNumberOfCategories

import org.hibernate.type.LongType; //导入依赖的package包/类
/**
 * This is a more efficient shortcut for writing "getCategories().size()", as that would require
 * to load all the categories first.
 *
 * @return The number of categories.
 */
public int getNumberOfCategories()
{
	BigInteger nrOfCategories = new BigInteger("0");

	long id = __getId();
	Session session = wiki.__getHibernateSession();
	 session.beginTransaction();
	Object returnValue = session
			.createNativeQuery("select count(pages) from page_categories where id = :pageid")
			.setParameter("pageid", id, LongType.INSTANCE).uniqueResult();
	 session.getTransaction().commit();

	if (returnValue != null) {
		nrOfCategories = (BigInteger) returnValue;
	}
	return nrOfCategories.intValue();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:24,代码来源:Page.java

示例8: getNumberOfInlinks

import org.hibernate.type.LongType; //导入依赖的package包/类
/**
 * This is a more efficient shortcut for writing "getInlinks().size()", as that would require to
 * load all the inlinks first.
 *
 * @return The number of inlinks.
 */
public int getNumberOfInlinks()
{
	BigInteger nrOfInlinks = new BigInteger("0");

	long id = __getId();
	Session session = wiki.__getHibernateSession();
	session.beginTransaction();
	Object returnValue = session
			.createNativeQuery("select count(pi.inLinks) from page_inlinks as pi where pi.id = :piid")
			.setParameter("piid", id, LongType.INSTANCE).uniqueResult();
	session.getTransaction().commit();

	if (returnValue != null) {
		nrOfInlinks = (BigInteger) returnValue;
	}
	return nrOfInlinks.intValue();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:24,代码来源:Page.java

示例9: getNumberOfOutlinks

import org.hibernate.type.LongType; //导入依赖的package包/类
/**
 * This is a more efficient shortcut for writing "getOutlinks().size()", as that would require
 * to load all the outlinks first.
 *
 * @return The number of outlinks.
 */
public int getNumberOfOutlinks()
{
	BigInteger nrOfOutlinks = new BigInteger("0");

	long id = __getId();
	Session session = wiki.__getHibernateSession();
	session.beginTransaction();
	Object returnValue = session
			.createNativeQuery("select count(outLinks) from page_outlinks where id = :id")
			.setParameter("id", id, LongType.INSTANCE).uniqueResult();
	session.getTransaction().commit();

	if (returnValue != null) {
		nrOfOutlinks = (BigInteger) returnValue;
	}
	return nrOfOutlinks.intValue();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:24,代码来源:Page.java

示例10: getNumberOfParents

import org.hibernate.type.LongType; //导入依赖的package包/类
/**
 * This is a more efficient shortcut for writing "getParents().size()", as that would require to load all the parents first.
 * @return The number of parents of this category.
 */
public int getNumberOfParents() {
    BigInteger nrOfInlinks = new BigInteger("0");

    long id = this.__getId();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery("select count(inLinks) from category_inlinks where id = :id")
        .setParameter("id", id, LongType.INSTANCE)
        .uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfInlinks = (BigInteger) returnValue;
    }
    return nrOfInlinks.intValue();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:21,代码来源:Category.java

示例11: getNumberOfChildren

import org.hibernate.type.LongType; //导入依赖的package包/类
/**
 * This is a more efficient shortcut for writing "getChildren().size()", as that would require to load all the children first.
 * @return The number of children of this category.
 */
public int getNumberOfChildren() {
    BigInteger nrOfOutlinks = new BigInteger("0");

    long id = this.__getId();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery("select count(outLinks) from category_outlinks where id = :id")
        .setParameter("id", id, LongType.INSTANCE)
        .uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfOutlinks = (BigInteger) returnValue;
    }
    return nrOfOutlinks.intValue();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:21,代码来源:Category.java

示例12: getNumberOfPages

import org.hibernate.type.LongType; //导入依赖的package包/类
/**
 * This is a more efficient shortcut for writing "getPages().size()", as that would require to load all the pages first.
 * @return The number of pages.
 */
public int getNumberOfPages() throws WikiApiException {
    BigInteger nrOfPages = new BigInteger("0");

    long id = this.__getId();
    Session session = this.wiki.__getHibernateSession();
    session.beginTransaction();
    Object returnValue = session.createNativeQuery("select count(pages) from category_pages where id = :id")
        .setParameter("id", id, LongType.INSTANCE)
        .uniqueResult();
    session.getTransaction().commit();

    if (returnValue != null) {
        nrOfPages = (BigInteger) returnValue;
    }
    return nrOfPages.intValue();
}
 
开发者ID:dkpro,项目名称:dkpro-jwpl,代码行数:21,代码来源:Category.java

示例13: getEntityId

import org.hibernate.type.LongType; //导入依赖的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));
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:26,代码来源:TranslationServiceImpl.java

示例14: getRankById

import org.hibernate.type.LongType; //导入依赖的package包/类
public Rank getRankById(final Long rankId) {
    if (log.isDebugEnabled()) {
        log.debug("getRankById: " + rankId + ")");
    }

    if (rankId == null) {
        throw new IllegalArgumentException("getRankById(): rankId is null");
    }

    if (!isRanksEnabled())
    {
        // This is 'warn' because it implies some code is aware of a rank, but ranks are disabled
        log.warn("getRankById invoked, but ranks are disabled");
        return null;
    }

    HibernateCallback<Rank> hcb = session -> {
        Query q = session.getNamedQuery(QUERY_BY_RANK_ID);
        q.setParameter("rankId", rankId, LongType.INSTANCE);
        return (Rank) q.uniqueResult();
    };

    Rank rank = getHibernateTemplate().execute(hcb);
    return rank;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:26,代码来源:RankManagerImpl.java

示例15: findAuthoredStatsForStudentByTopicId

import org.hibernate.type.LongType; //导入依赖的package包/类
public List<UserStatistics> findAuthoredStatsForStudentByTopicId(final String studentId, final Long topicId) {
	if (log.isDebugEnabled()) log.debug("findAuthoredStatsForStudentByTopicId()");

	HibernateCallback hcb = session -> {
        Query q = session.getNamedQuery("findAuthoredStatsForStudentByTopicId");
        q.setParameter("topicId", topicId, LongType.INSTANCE);
        q.setParameter("userId", studentId, StringType.INSTANCE);
        return q.list();
    };
	List<UserStatistics> returnList = new ArrayList<UserStatistics>();
	List<Object[]> results = (List<Object[]>)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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:MessageForumsMessageManagerImpl.java


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