當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。