Hi,

The page cannot be a bean, so it cannot be @Stateless.
Better create a stateless EJB which has a reference to @PersistenceUnit:

class MyPage extends WebPage {

  @EJB
  private MyBean ejb;

  ....
  ejb.store(entity)

}

interface MyBean {
  void store(Entity entity)
}

@Stateless
class MyBeanImpl implements MyBean {
   @PersistenceUnit
   private EntityManagerFactory emf;

    @Override
    public void store(Entity entity) {
        emf.getEntityManager().persist(entity);
    }
}

P.S. I haven't used JavaEE since its early days of 1.5 version so excuse me
if I don't follow some best practices.


On Fri, Dec 21, 2012 at 2:30 PM, Lucio Crusca <lu...@sulweb.org> wrote:

> Hello *,
>
> I've started this short thread on the tomEE users ml:
>
> http://markmail.org/message/3asqvvptnkieknq5
>
> The final answer sounds to me like "if you want to use resources injection
> through JPA annotations in a wicket application, your best bet is Java-EE-
> Inject"
>
> https://github.com/wicketstuff/core/wiki/Java-EE-Inject
>
> which in turn states that:
>
> "With JavaEE Inject you can use in your wicket components three
> annotations:
> @EJB, @PersistenceUnit, @Resource".
>
> What about @Entity, @Table, @Id, @GeneratedValue and friends?
>
> What's the simplest way to use JPA annotations and dependency injection
> threreof in a wicket application?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to