本文整理汇总了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 );
}
示例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;
}
示例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;
}
}