Inject EJB into domain object with Java EE 6

前端 未结 3 1699
-上瘾入骨i
-上瘾入骨i 2021-01-04 14:08

How can I inject an EJB into a domain object (an JPA entity) with Java EE 6?

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 14:55

    You would typically not do this simply because domain objects come out of the database as opposed to the container and therefore injecting services isn't as straight forward.

    This does not mean however that you should not do this.

    You know what your system is meant to achieve and which other systems it interacts with. This knowledge will effect the decision I'd imagine.

    See Active Record link. As I meanted in my comment typically small systems would choose this route.

提交回复
热议问题