java - Inject entityManager into custom Hibernate Interceptor class -


i want inject entitymanager hibernate on hibernate interceptor class. i'm using ejbs , jboss. transaction jta , provider org.hibernate.ejb.hibernatepersistence.

i tried that:

@stateless(name = "historicinterceptor") @transactionattribute(transactionattributetype.requires_new) public class historicinterceptorimpl extends emptyinterceptor implements historicinterceptor {  @persistencecontext(name = "windi") private entitymanager em;  // overriden methods, etc  } 

but reference entitymanager null.

is behaviour expected? how can access entitymanager within interceptor class?

i had given on exact solution. instead, i've created class has ejb annotations. interceptor call ejb using provider class lookup ejb classes on context of application. there, entitymanager correctly associated.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -