• Post Reply Bookmark Topic Watch Topic
  • New Topic

Quick query regarding Beans and Interfaces  RSS feed

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been looking at some examples on the Net and I've noticed that sometimes Beans implement the Interface sometimes the Session.



I was just wondering why this is?
I have been writinmg beans using the 'Implements Interface' style, is there a specific reason for doing it this other way?
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Keith,

Annotations were added recently in EJB 3.0 and the first type of defining a Stateless or Stateful session bean was introduced in EJB 3.0. The annotations are translated during compile time or runtime.

The second syntax was pre EJB 3.0 (EJB 1.0, 1.1, 2.0, 2.1) when your stateful or stateless session bean had to explicitly extend from SessionBean. You can still do this and it will be supported but in my opinion the newer approach is more elegant.
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To continue with my question...

How do you declare a bean Entity/Session Sateless/Stateful in this newer version?

Example coding would be great, please :-D

---

Continuing from this, is this the best way to define Session & Entity Beans:-

@Stateless/Stateful
public class MyBean implements myInterface {

@Entity
@Table(name = "myTable")
public class myEntityBean implements myInterface {
[ September 04, 2007: Message edited by: Keith Wilson ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!