0
public class SeatAllocationService implements Serializable {     
  @Inject   
  EntityManager entityManager; 
  //... 
}

I was reading Ticket-monster.2.1.6.final. This annotation made me confused. Looking up Oracle and google didn't help: According to oracle doc, @inject Identifies injectable constructors, methods, and fields. However, what is injectable constructors?

Nya
  • 310
  • 2
  • 10

1 Answers1

0

According to the specifications:

The @Inject annotation defined by the Dependency Injection for Java specification identifies an injected field which is initialized by the container when the bean is instantiated, or an initializer method which is called by the container after the bean is instantiated, with injected parameters.

The @Inject annotation is part of Java Dependency Injection. CDI (Content and Dependency Injection) has been updated voor JavaEE 7 but was allready a part of JavaEE 6. Read documentation about CDI here:

http://docs.oracle.com/javaee/6/tutorial/doc/giwhb.html

For this specific example. The EntityManager should be annotated with @PersistenceContext not with @Inject. Refer to this SO question.

Community
  • 1
  • 1
Martijn Burger
  • 7,315
  • 8
  • 54
  • 94