문제

I have an entity:-

@Entity
@Table
public class Application{

@Inject
@QualifierName
private Event<Application> applicationXXX;

public void someMethod(){
 applicationXXX.fire(someObject);
}
//BODY
} 

In MyEventhandler Class , I'm using :

public void onXXX(@Observes @QualifierName Object someObject){

}

the injection in Application class for Event --- applicationXXX is null.

however the same injection if i do in some other class then it's not null and working.

can any one help me and point out what I'm missing here ???

can't i inject CDI events in Entity ??? or is there any other method ???

Thanks

도움이 되었습니까?

해결책

JPA entities are special, because they're already under management from JPA you need to have producer for them, even then I really doubt the injection would still work. I suggest not using CDI concepts within JPA entities.

For this case I'd call some other middle man class to handle the event firing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top