-
1. Re: Injecting a component
monkeyden Feb 7, 2011 2:15 PM (in response to yurien1986)Entity beans cannot intrinsically be Seam components. You'll have to outject it to some scope (SESSION, CONVERSATION, APPLICATION, etc.) first. That is to say, you must first have @Out somewhere.
@Out(scope=CONVERSATION) private TnDosis dosis;
...then @In will work. Or, you could also create a subclass of EntityHome, to manage it's lifecycle:
@Name("TnDosisHome") public class TnDosisHome extends EntityHome<TnDosis>{ ... }
...and inject that instead. If you're not already aware, EntityHome is used for entity CRUD operations and EntityQuery is used for entity searches.
-
2. Re: Injecting a component
yurien1986 Feb 7, 2011 7:16 PM (in response to yurien1986)ok,thank you very much my friend, i did the same thing you told me an it works, but now i am proving to inject another entity bean,but in this case without put it an @name,like i do with the Entity Manager. Ex:
@In
private EntityManager entityManager;@In
private TnDosis tnDosis;I tried this, and it threw an error.
Apologize me for the inconvenience..Thanks a lot....
-
3. Re: Injecting a component
monkeyden Feb 8, 2011 11:19 AM (in response to yurien1986)I guess I should have asked this straight away but what is it exactly that you're trying to do? Do you have a Seam component which has already created that TnDosis for you?
@In private TnDosis tnDosis;
What that code says to Seam is,
I require an instance of TnDosis which can be found under the name 'tnDosis'. Go find it in any scope for me.
Seam assumes you know what you're talking about so, off it goes. It doesn't find it and tells you in the best way it knows how...an exception. It cannot magically create it for you because it can only do that with Seam components and @Entity beans cannot be Seam components.