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


Java Hibernate.getClass方法代码示例

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


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

示例1: getIdentifier

import org.hibernate.Hibernate; //导入方法依赖的package包/类
public Object getIdentifier(Object entity) {
	final Class entityClass = Hibernate.getClass( entity );
	final ClassMetadata classMetadata = emf.getSessionFactory().getClassMetadata( entityClass );
	if (classMetadata == null) {
		throw new IllegalArgumentException( entityClass + " is not an entity" );
	}
	//TODO does that work for @IdClass?
	return classMetadata.getIdentifier( entity, EntityMode.POJO );
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:10,代码来源:EntityManagerFactoryImpl.java

示例2: getNearestLeaderSelectionActivity

import org.hibernate.Hibernate; //导入方法依赖的package包/类
/**
    * Finds the nearest Leader Select activity. Works recursively. Tries to find Leader Select activity in the previous
    * activities set first, and then inside the parent set.
    */
   @SuppressWarnings("rawtypes")
   private Activity getNearestLeaderSelectionActivity(Activity activity, Integer userId, Long lessonId) {
// check if current activity is Leader Select one. if so - stop searching and return it.
Class activityClass = Hibernate.getClass(activity);
if (activityClass.equals(ToolActivity.class)) {
    ToolActivity toolActivity;

    // activity is loaded as proxy due to lazy loading and in order to prevent quering DB we just re-initialize
    // it here again
    Hibernate.initialize(activity);
    if (activity instanceof HibernateProxy) {
	toolActivity = (ToolActivity) ((HibernateProxy) activity).getHibernateLazyInitializer()
		.getImplementation();
    } else {
	toolActivity = (ToolActivity) activity;
    }

    if (ILamsToolService.LEADER_SELECTION_TOOL_SIGNATURE.equals(toolActivity.getTool().getToolSignature())) {
	return activity;
    }

//in case of a floating activity
} else if (activityClass.equals(FloatingActivity.class)) {
    LearnerProgress learnerProgress = lessonService.getUserProgressForLesson(userId, lessonId);
    Map<Activity, CompletedActivityProgress> completedActivities = learnerProgress.getCompletedActivities();

    //find the earliest finished Leader Select Activity
    Date leaderSelectActivityFinishDate = null;
    Activity leaderSelectionActivity = null;
    for (Activity completedActivity : completedActivities.keySet()) {

	if (completedActivity instanceof ToolActivity) {
	    ToolActivity completedToolActivity = (ToolActivity) completedActivity;
	    if (ILamsToolService.LEADER_SELECTION_TOOL_SIGNATURE
		    .equals(completedToolActivity.getTool().getToolSignature())) {
		Date finishDate = completedActivities.get(completedActivity).getFinishDate();

		if ((leaderSelectActivityFinishDate == null)
			|| (finishDate.compareTo(leaderSelectActivityFinishDate) < 0)) {
		    leaderSelectionActivity = completedToolActivity;
		    leaderSelectActivityFinishDate = completedActivities.get(completedActivity).getFinishDate();
		}

	    }
	}

    }

    return leaderSelectionActivity;
}

// check previous activity
Transition transitionTo = activity.getTransitionTo();
if (transitionTo != null) {
    Activity fromActivity = transitionTo.getFromActivity();
    return getNearestLeaderSelectionActivity(fromActivity, userId, lessonId);
}

// check parent activity
Activity parent = activity.getParentActivity();
if (parent != null) {
    return getNearestLeaderSelectionActivity(parent, userId, lessonId);
}

return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:71,代码来源:LamsToolService.java

示例3: findPrecedingConfidenceProvidingActivities

import org.hibernate.Hibernate; //导入方法依赖的package包/类
/**
    * Finds all preceding activities that can provide confidence levels (currently only Assessment and MCQ provide
    * them). Please note, it does not check whether enableConfidenceLevels advanced option is ON in those activities.
    */
   @SuppressWarnings("rawtypes")
   private void findPrecedingConfidenceProvidingActivities(Activity activity, Set<Long> confidenceProvidingActivityIds) {
// check if current activity is Leader Select one. if so - stop searching and return it.
Class activityClass = Hibernate.getClass(activity);
if (activityClass.equals(ToolActivity.class)) {
    ToolActivity toolActivity;

    // activity is loaded as proxy due to lazy loading and in order to prevent quering DB we just re-initialize
    // it here again
    Hibernate.initialize(activity);
    if (activity instanceof HibernateProxy) {
	toolActivity = (ToolActivity) ((HibernateProxy) activity).getHibernateLazyInitializer()
		.getImplementation();
    } else {
	toolActivity = (ToolActivity) activity;
    }

    String toolSignature = toolActivity.getTool().getToolSignature();
    if (TOOL_SIGNATURE_ASSESSMENT.equals(toolSignature) || TOOL_SIGNATURE_MCQ.equals(toolSignature)) {
	confidenceProvidingActivityIds.add(toolActivity.getActivityId());
    }

//in case of a floating activity - return all available confidence providing activities
} else if (activityClass.equals(FloatingActivity.class)) {
    Set<Activity> activities = activity.getLearningDesign().getActivities();
    for (Activity activityIter : activities) {
	if (activityIter instanceof ToolActivity) {
	    String toolSignatureIter = ((ToolActivity) activityIter).getTool().getToolSignature();
	    if (TOOL_SIGNATURE_ASSESSMENT.equals(toolSignatureIter)
		    || TOOL_SIGNATURE_MCQ.equals(toolSignatureIter)) {
		confidenceProvidingActivityIds.add(activityIter.getActivityId());
	    }
	}
    }
    return;
}

// check previous activity
Transition transitionTo = activity.getTransitionTo();
if (transitionTo != null) {
    Activity fromActivity = transitionTo.getFromActivity();
    findPrecedingConfidenceProvidingActivities(fromActivity, confidenceProvidingActivityIds);
    return;
}

// check parent activity
Activity parent = activity.getParentActivity();
if (parent != null) {
    findPrecedingConfidenceProvidingActivities(parent, confidenceProvidingActivityIds);
    return;
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:57,代码来源:LamsToolService.java


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