Re: JPA annotations

2013-01-02 Thread Jochen Mader
I think you should first understand what the different JPA-annotations
actually do.
@Entity, @Table, @Id, @GeneratedValue are annotations used on the
entity level to tell the mapper what to do with properties. These
informations are of no interest to Wicket.
@EJB, @PersistenceUnit, @Resource are annotations used for isntances
injectable by an appropriate container (which can bee CDI, Guice
Spring, ...).

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: JPA annotations

2012-12-31 Thread gal
Hi,

You might want to take a look @  Wicket CDI
https://www.42lines.net/2011/11/15/integrating-cdi-into-wicket/   which
with a few lines of code you can use @Inject and of course use all the
aforementioned annotations for JPA and using CDI doesn't require Spring.

You might also want to take a look @  Weld
http://www.seamframework.org/Weld  .

HTH,

Gal.




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/JPA-annotations-tp4655001p4655111.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: JPA annotations

2012-12-23 Thread Ron Smits
check http://jeff-schwartz.blogspot.nl/2011/03/java-ee6-wicket.html its a
good series of articles about using Java EE and wicket

I Haven't Lost My Mind - It's Backed Up On Disk Somewhere


On Fri, Dec 21, 2012 at 1: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




Re: JPA annotations

2012-12-23 Thread martin.dilger
Hi,

I really don't understand your question.

You want to know how to get jpa-annotations to work.
Well, you just need to get hold of an entitymanager.
If you ask me, go with spring, it's easier than jee or even
Guice.

Regards Martin




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/JPA-annotations-tp4655001p4655025.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: JPA annotations

2012-12-21 Thread Martin Grigorov
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/


Re: JPA annotations

2012-12-21 Thread Lucio Crusca
In data venerdì 21 dicembre 2012 13:41:36, Martin Grigorov ha scritto:
 Hi,
 
 The page cannot be a bean, so it cannot be @Stateless.
 Better create a stateless EJB which has a reference to @PersistenceUnit:

Thanks for pointing that out.

 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);
 }
 }

Ok, but what about Java-EE-Inject? Is that the standard (most widely used) way 
to integrate JPA (or hibernate) into wicket applications?



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: JPA annotations

2012-12-21 Thread Martin Grigorov
On Fri, Dec 21, 2012 at 4:07 PM, Lucio Crusca lu...@sulweb.org wrote:

 In data venerdì 21 dicembre 2012 13:41:36, Martin Grigorov ha scritto:
  Hi,
 
  The page cannot be a bean, so it cannot be @Stateless.
  Better create a stateless EJB which has a reference to @PersistenceUnit:

 Thanks for pointing that out.

  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);
  }
  }

 Ok, but what about Java-EE-Inject? Is that the standard (most widely used)
 way
 to integrate JPA (or hibernate) into wicket applications?


I think Spring is still dominant in this area.




 -
 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/


Re: JPA annotations

2012-12-21 Thread Lucio Crusca
In data venerdì 21 dicembre 2012 15:10:11, Martin Grigorov ha scritto:
 
 I think Spring is still dominant in this area.

Hmm, I've had a look, too much xml for my taste... what about Guice? Can it be 
used as alternative to Spring to have JPA annotations working with Wicket?

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: JPA annotations

2012-12-21 Thread Martin Grigorov
Spring Java Config, @Configuration, @Bean


On Fri, Dec 21, 2012 at 5:58 PM, Lucio Crusca lu...@sulweb.org wrote:

 In data venerdì 21 dicembre 2012 15:10:11, Martin Grigorov ha scritto:
 
  I think Spring is still dominant in this area.

 Hmm, I've had a look, too much xml for my taste... what about Guice? Can
 it be
 used as alternative to Spring to have JPA annotations working with Wicket?

 -
 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/


Re: JPA annotations

2012-12-21 Thread Lucio Crusca
In data venerdì 21 dicembre 2012 17:01:59, Martin Grigorov ha scritto:
 Spring Java Config, @Configuration, @Bean

Ok thanks, but there are other things that make me prefer Guice over Spring, 
if possible. Is it possible? Can Guice be used to make JPA annotations work in 
wicket apps?


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: JPA annotations

2012-12-21 Thread Martin Grigorov
http://jweekend.co.uk/dev/LegUp

You may need to upgrade dependencies' versions.


On Fri, Dec 21, 2012 at 6:13 PM, Lucio Crusca lu...@sulweb.org wrote:

 In data venerdì 21 dicembre 2012 17:01:59, Martin Grigorov ha scritto:
  Spring Java Config, @Configuration, @Bean

 Ok thanks, but there are other things that make me prefer Guice over
 Spring,
 if possible. Is it possible? Can Guice be used to make JPA annotations
 work in
 wicket apps?


 -
 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/


RE: JPA annotations

2012-12-21 Thread Chris Colman
I thought anything EJB was taken off the menu years ago to stop people
getting very sick - Doctor's orders ;)


-Original Message-
From: Martin Grigorov [mailto:mgrigo...@apache.org]
Sent: Friday, 21 December 2012 11:42 PM
To: users@wicket.apache.org
Subject: Re: JPA annotations

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/

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org