/**
* Helper method for event reading.
*
* @param actor
* User saving event.
* @param occurrenceTime
* Occurance time.
* @param subKey
* Key of subscription.
* @param eventType
* The type of the event to read
* @return Event.
* @throws Exception
*/
private GatheredEvent readEvent(final String actor,
final long occurrenceTime, final long subKey,
final EventType eventType) throws Exception {
GatheredEvent eventLocal = runTX(new Callable<GatheredEvent>() {
@Override
public GatheredEvent call() throws Exception {
long key = -1;
Query query = mgr.createQuery(
"select c from GatheredEvent c where c.dataContainer.actor=:actor and "
+ "c.dataContainer.occurrenceTime=:occurrencetime and "
+ "c.dataContainer.subscriptionTKey=:subscriptionTKey and "
+ "c.dataContainer.type=:type");
query.setParameter("actor", actor);
query.setParameter("occurrencetime",
Long.valueOf(occurrenceTime));
query.setParameter("subscriptionTKey", Long.valueOf(subKey));
query.setParameter("type", eventType);
Iterator<GatheredEvent> gatheredEventIterator = ParameterizedTypes
.iterator(query.getResultList(), GatheredEvent.class);
if (gatheredEventIterator.hasNext()) {
key = gatheredEventIterator.next().getKey();
}
return mgr.find(GatheredEvent.class, key);
}
});
return eventLocal;
}
EventServiceBeanIT.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:oscm
作者:
评论列表
文章目录