-
1. Re: Are @EntityListeners with injection possible?
keithnaas Mar 12, 2008 4:27 PM (in response to craig)Craig,
Don't do annotation based injection in an EntityListener. Last time I checked, the lifecycle of the object is not controlled by Seam.
Try
Component.getInstance("entityManager");//where entityManager is the name of the entityManager in your components.xml
-
2. Re: Are @EntityListeners with injection possible?
craig Mar 12, 2008 4:36 PM (in response to craig)Thats great works well.
Is this a good design pattern or should i be using seams event model and raising prePersist events?
I dont want to use the prePersist annotation in my entity as i need to access the db for get a specific value at point of persist.
Thanks
Craig
-
3. Re: Are @EntityListeners with injection possible?
keithnaas Mar 12, 2008 4:44 PM (in response to craig)Hmmm...I suppose it depends on what kind of logic will be executing in prepersist. If its simply a matter of putting some audit information somewhere...just use a prepersist. But if you need to do something really crazy, I would probably look at using seam events. Unfortunately, there's a million way to skin this cat.
-
4. Re: Are @EntityListeners with injection possible?
monkeyden May 14, 2009 8:04 PM (in response to craig)Seam 2.0.3.CR1
I tried this with:
identity = (Identity)Component.getInstance("identity");
also tried the more verbose variety:
identity = (Identity)Component.getInstance("org.jboss.seam.security.identity");
and identity comes up null. It does get into the method ok. Any ideas?
-
5. Re: Are @EntityListeners with injection possible?
sean.tozer Mar 3, 2011 4:27 PM (in response to craig)This is an old thread, but I came across it while looking for a solution, and wanted to post back how I eventually solved it.
Identity identity = (Identity)Component.getInstance(Identity.class);
works to manually inject the identity component, while the string identifier does not.