SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anyone worked with EJB3?

    Hi,

    I have a DB project I'm working on and I'm interested in trying out EJB 3 although I really don't know much about it. I've done plenty of work with EJB 2 but from what I've heard EJB 3 is very different. Also EJB 2 is a bit heavy for this project. So I guess I just want to know what the major differences are between EJB 2 and 3 as well as any general opinions you may have on EJB 3 (good/bad/stay away...).

    Thanks

  2. #2
    SitePoint Addict dAEk's Avatar
    Join Date
    Oct 2003
    Location
    Stockholm, Sweden
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    EJB 3 is a lot easier to work with since you don't have to implement a lot of interfaces and empty method stubs. However, my experience with EJB 2 is non-existent and I have only done one project with EJB 3. But the general consensus is that EJB is the future and that it makes developers more productive. You may also chose from using annotations or XML for database-to-object mappings, which is nice.

    I'd never use EJB 2 if I got to make the decisions.
    David Shamloo-Ekblad

    Go Habs! | For music addicts: Last.fm, SongMeanings

  3. #3
    SitePoint Member tattobit's Avatar
    Join Date
    Feb 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm doing a large project in EJB 3 right now. Here's some of my thoughts:

    1. In EJB 3, you model object relationships vs. database relationships. On this project, I was fortunate enough to have the opportunity to create a new database so my object model and db model match up quite nicely.

    2. The complexity of ejb 2.0 was greatly simplified so that your ejbs basically become java classes with annotations. If you learn those annotations, you should easily be able to make the leap to 3.0. There's only one or two xml files to worry about and those are very simple.

    3. Cascading relationships can be a challenge to design in terms of knowing when you should set one up vs. doing individual lookups and/or updates. Simple example I can give is, say you have an order and line items, you can set up your ejbs to update line items when you persist an order or you could update line items individually and then update order. When the relationships get more complex, especially when you have multiple relationships between objects, this can get tricky.

    4. Development is a bit harder and longer. It's much faster for simpler apps to be done in JSP/java all in one project in my IDE vs. a web and ejb project. Your local server is going to take longer in loading all the ejbs.

    5. Database changes don't reflect in the application. Depending on how you set up your ejbs to load, changing values via the backend will require a server restart. This can get quite annoying.

    6. Unless you can make a good case for ejbs, I wouldn't use them over a simpler java/jdbc app. If you need really fine grain control or have very intense transaction requirements, then I'd recommend ejbs.

  4. #4
    SitePoint Zealot sherl0ck's Avatar
    Join Date
    Aug 2008
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    much much more simple than EJB2.
    too bad it kind bit late. It should be done years ago.

  5. #5
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the response. Yes EJB2 was very complicated. It worked well in certain situations where fine grain security was required and was also good for things like transaction management. But they were definitely slower on the performance side. EJB3 sounds nicer, but I'm looking at hibernate as an option. I've done some tutorials with that but never used it for a serious project.

    For this project it'll probably be faster to write it just using JDBC but I think in the long run I'd prefer to use either EJB3 or Hibernate. I think it's just more scalable and easier to maintain. Also I'll be dealing with many tables, probably around 10, with 10-20 columns each.

    But for now I'm still far from implementing anything. I need to first design the database based on the specs I have... a load of fun that will be But certainly the most important aspect of this project.

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,381
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rozner View Post
    Thanks for the response. Yes EJB2 was very complicated. It worked well in certain situations where fine grain security was required and was also good for things like transaction management. But they were definitely slower on the performance side. EJB3 sounds nicer, but I'm looking at hibernate as an option. I've done some tutorials with that but never used it for a serious project.

    For this project it'll probably be faster to write it just using JDBC but I think in the long run I'd prefer to use either EJB3 or Hibernate. I think it's just more scalable and easier to maintain. Also I'll be dealing with many tables, probably around 10, with 10-20 columns each.

    But for now I'm still far from implementing anything. I need to first design the database based on the specs I have... a load of fun that will be But certainly the most important aspect of this project.
    I think there's some confusion here. EJB3 is a spec not implementation. Meaning, you can use EJB 3 API using hibernate implementation. The founder of Hibernate is a heavy influencer in EJB 3 community. Anyways, do not be afraid to use it! EJB3+Hibernate+Spring... so damn awesome! It's foolish to miss this opportunity to use them!! please use them!!!!!!!! you'll never ever go back. To get this started look for an example that uses EJB3 w/ Spring. Again, please do.

  7. #7
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,381
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    In fact there's auto generation code based on your database schema.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •