-
1. Re: How to get EventDefinitions for ResourceType via RHQ API
pilhuhn Sep 19, 2012 4:10 AM (in response to bova)The snippet of your code you are showing looks good to me. In fact I am doing almost the same in the REST-Api's EventHandlerBean.addEventSource
The eventDefinitions are a 1:n relation on the ResourceType and are thus lazy loaded. In theory if no EntityManager is available you should get a lazy load exception.
In what context are you running that code?
Does the 'subject' have enough access rights?
-
2. Re: How to get EventDefinitions for ResourceType via RHQ API
lkrejci Sep 19, 2012 4:18 AM (in response to bova)As Heiko said, the Event definitions are lazy loaded, so for your code to work, you must not leave the transactional context of the EntityManager.
If for some reason you're not able to make that happen, you can try using the criteria queries:
ResourceTypeCriteria rtc = new ResourceTypeCriteria();
rtc.addFilterId(<ID>);
rtc.fetchEventDefinitions(true);
List<ResoureType> results = getResourceTypeManagerLocal().findResourceTypesByCriteria(<SUBJECT>, rtc);
-
3. Re: How to get EventDefinitions for ResourceType via RHQ API
bova Sep 19, 2012 4:29 AM (in response to lkrejci)Lukas and Heiko, thanks a lot for this usefull answer
seems that key things here is rtc.fetchEventDefinitions(true);
because I tried this method early but without setting fetchEventDefinitions to true
Now it works - thank you !!!!!!