EJB2 vs. EJB3

Hi everyone,
I am trying to understand the language when speaking about EJB2 vs. EJB 3. In the course I am taking, the following question or topic was presented:
"Discuss the difference between container-managed and bean-managed persistence and when you would use each."
Now I took this to refer to EJB 2 Entity Beans and answered along those lines. One of the students posted the following:
"When an entity bean does its job of manipulating data, that persistence functionality needs management. We have a choice of container-managed or bean-managed persistence (CMP or BMP). CMP is a function of the EJB container provided by the EJB server. In this scenario, "an entity bean is mapped to a database table that is dedicated to the purpose of storing instances of that entity bean (Mukhar, et al, 2006)." The EntityManager (javax.persistence.EntityManager) interface is used in code to find beans in order to manipulate them (persist, remove, find). All of this gives us a way to manipulate an abstraction of the data we are persisting - for example, rather than performing direct SQL statements, our code performs bean operations, even using the EJB Query Language. We can think of a single entity bean instance using CMP as a a single row on a table. As such, each entity bean must have a unique primary key just as we would expect on a table row. This primary key can be designated by the developer by specifying a bean attribute or the container can maintain the uniqueness via the @Id (javax.persistence.Id) metadata descriptor."
Note the reference to EntityManager, which is, as I understand it, a EJB 3 construct and manages Entity classes (EJB 3) not Entity Beans (EJB 2). Do you think this student is confusing EJB 2 and EJB 3? Or is it I who is totally confused, lol?
Thanks!!

No takers?
Maybe I just posted too much text. In essence these are my questions:
1) Is Container Managed Persistence (CMP) a EJB 2 concept that does not apply in EJB 3 and JPA? That is, I think in EJB 3 we would have Persistence Provider Managed Persistence, to call it something, instead of CMP.
2) The EntityManager is the EJB 3 Persistence Provider and does not apply to EJB 2 Entity Beans?
I think in my class everyone is very confused between EJB 2 and EJB 3 concepts and I would appreciate any confirmation. It may be I who is confused.
Thanks!
You do not need to continue reading from here. I added the other learner's statement below, without italics this time, for reference. My complaint is he seems to imply EntityManager manages Entity Beans. I think it only manages Entity classes not Entity Beans.
"When an entity bean does its job of manipulating data, that persistence functionality needs management. We have a choice of container-managed or bean-managed persistence (CMP or BMP). CMP is a function of the EJB container provided by the EJB server. In this scenario, "an entity bean is mapped to a database table that is dedicated to the purpose of storing instances of that entity bean (Mukhar, et al, 2006)." The EntityManager (javax.persistence.EntityManager) interface is used in code to find beans in order to manipulate them (persist, remove, find). All of this gives us a way to manipulate an abstraction of the data we are persisting - for example, rather than performing direct SQL statements, our code performs bean operations, even using the EJB Query Language. We can think of a single entity bean instance using CMP as a a single row on a table. As such, each entity bean must have a unique primary key just as we would expect on a table row. This primary key can be designated by the developer by specifying a bean attribute or the container can maintain the uniqueness via the @Id (javax.persistence.Id) metadata descriptor."

Similar Messages

  • Novice EJB2 to EJB3 Conversion Question

    I would like to convert my stateless remote session beans to EJB3 using annotations. Can this be done incrementally?
    My first attempt, after adding the appropriate annotations, was to comment-out the session element for one of my beans in the ejb-jar.xml file. When I deployed this using weblogic.Deployer, it simply was not deployed. No error messages or warnings were evident.
    I wondered if I must convert my ejb-jar.xmll from the old DTD-based format to the new schema-based format. So, I used weblogic.DDConverter. Here is the result:
    C:\svn\dmo.02.05\build\packager\stag\assemble\server\applications>java weblogic.
    DDConverter -d temp demo.ear
    [DDConverter] START Converting EAR demo.ear
    java.lang.NullPointerException
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:462)
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:406)
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.java:68)
    at weblogic.application.ddconvert.DDConverter.runBody(DDConverter.java:157)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.application.ddconvert.DDConverter.main(DDConverter.java:177)
    at weblogic.DDConverter.main(DDConverter.java:10)weblogic.application.ddconvert.DDConvertException: java.lang.NullPointerException
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.java:88)
    at weblogic.application.ddconvert.DDConverter.runBody(DDConverter.java:157)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.application.ddconvert.DDConverter.main(DDConverter.java:177)
    at weblogic.DDConverter.main(DDConverter.java:10)
    Caused by: java.lang.NullPointerException
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:462)
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:406)
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.java:68)
    ... 5 more
    Any advice would be appreciated.

    I would like to convert my stateless remote session beans to EJB3 using annotations. Can this be done incrementally?
    My first attempt, after adding the appropriate annotations, was to comment-out the session element for one of my beans in the ejb-jar.xml file. When I deployed this using weblogic.Deployer, it simply was not deployed. No error messages or warnings were evident.
    I wondered if I must convert my ejb-jar.xmll from the old DTD-based format to the new schema-based format. So, I used weblogic.DDConverter. Here is the result:
    C:\svn\dmo.02.05\build\packager\stag\assemble\server\applications>java weblogic.
    DDConverter -d temp demo.ear
    [DDConverter] START Converting EAR demo.ear
    java.lang.NullPointerException
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:462)
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:406)
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.java:68)
    at weblogic.application.ddconvert.DDConverter.runBody(DDConverter.java:157)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.application.ddconvert.DDConverter.main(DDConverter.java:177)
    at weblogic.DDConverter.main(DDConverter.java:10)weblogic.application.ddconvert.DDConvertException: java.lang.NullPointerException
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.java:88)
    at weblogic.application.ddconvert.DDConverter.runBody(DDConverter.java:157)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.application.ddconvert.DDConverter.main(DDConverter.java:177)
    at weblogic.DDConverter.main(DDConverter.java:10)
    Caused by: java.lang.NullPointerException
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:462)
    at weblogic.descriptor.BasicDescriptorManager.writeDescriptorBeanAsXML(BasicDescriptorManager.java:406)
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.java:68)
    ... 5 more
    Any advice would be appreciated.

  • How to access same ejb from different applications

    Hi
    I have two applications (.ear). Each application has 4 EJBs. These EJBs are same in both applications including their names. JNDI names are also same in each application.
    in detail
    ApplicationA (appA.ear) contains
    web1.war
    ejb1.jar
    ejb2.jar
    ejb3.jar
    ejb4.jar
    and
    ApplicationB (appB.ear) contains
    web2.war
    ejb1.jar
    ejb2.jar
    ejb3.jar
    ejb4.jar
    both web1.war and web2.war has same JNDI references to these EJBs.
    The problem:
    If you access the applicationA, works fine. But if you access applicationB, it throws ClassCast Exception
    After restarting.....
    If you access the applicationB, works fine. But if you access applicationA, it throws ClassCast Exception
    Both the applications are not working same time.
    I suspect that It is because both applications have same ejbs and with same JNDI names.
    Please validate.
    Thanks
    Srinivas

    Hi Timo,
    Very sorry for reply so late!
    My case is that accessing a task flow(MaintainJobInstanceTaskFlow) through NevigationBean of UI Shell. please see the coding as following:
    taskFlowId_SubNavigation =
    "/WEB-INF/oracle/apps/pas/shell/ui/flow/SystemSetupTabFlow.xml#SystemSetupTabFlow";
    taskFlowId_TaskListNavigation =
    "/WEB-INF/oracle/apps/pas/shell/ui/flow/SystemSetupTaskListFlow.xml#SystemSetupTaskListFlow";
    taskFlowId_QuickSearch =
    "/WEB-INF/oracle/apps/pas/shell/ui/flow/SystemSetupQuickSearchFlow.xml#SystemSetupQuickSearchFlow";
    taskFlowId_LocalArea =
    "/WEB-INF/oracle/apps/pas/transactions/ui/flow/MaintainJobInstanceTaskFlow.xml#MaintainJobInstanceTaskFlow";
    break;
    In my case, how to transfer parameters to MaintainJobInstanceTaskFlow in java?
    Thanks!
    Susan

  • Tracing used EBJs

    Hi,
    We have an external "tracer" that needs to track which EJBs are used in an J2EE application to satisfy each individual client request. This "tracer" is an external program, which means that it runs in a different machine than the application server machine. What we need to do is to instrument/modify the middleware and/or communications layer between EJBs so that it sends a packet to the "tracer" indicating the EJBs used in a request. We think that we have to modify the EJB container to do this (but not sure). For example, when a client enters to the Welcome page, the application runs EJB1, EJB2 and EJB3. For this request, the "tracer" needs to receive a packet indicating that these three EJBs where used.
    Any suggestion/idea?

    There are actually two ways to do this in GlassFish using the Callflow Mechanism. The Callflow layer tracks multiple events like RequestStart, RequestEnd, MethodStart and Method End. You will need to look at the MethodStart events to determine if the call is for an EJB. The Callflow layer will give you detailed information about the EJB.
    The first mechanism has been used by our self management infrastructure whereby they implement a listener with the Callflow Agent. Once the callflow method is hit an event is thrown to the listener that they capture and process.
    The Pro: the Listener can easily be registered with the agent and is exposed as an external interface.
    The Con: The event is thrown when the call is being is executed, so essentially the processing time that your handler takes is added to the call processing time.
    The relevant files are
    http://fisheye5.cenqua.com/browse/glassfish/appserv-core/src/java/com/sun/enterprise/admin/selfmanagement/event/CallflowEventListener.java
    The public interfaces are at
    http://fisheye5.cenqua.com/browse/glassfish/appserv-commons/src/java/com/sun/enterprise/admin/monitor/callflow
    The second mechanism that I have just added about 3-4 weeks back sends events asynchronously to a different handler. The biggest advantage is that your method call does not have pay for your handler processing code time. It takes advantage of the efficient asynchronous code that we have added to decouple our database writing from the call processing times.
    The con: Since we have just added this code, I have not yet exposed this in the appserv-commons directory but we can easily work that out if this is something that satisfies your needs.
    You will need to implement a Handler and register it with the handler chain
    http://fisheye5.cenqua.com/browse/glassfish/admin/monitor/src/java/com/sun/enterprise/admin/monitor/callflow
    and implement the handle method. The handle method gets a bulk of TransferObjects (since this is handled asynchronously - we bullk them up). You will need to see if a particular TO is a type of MethodStartTO and extract the relevant information from there.
    Once you have implemented either of these, you can start callflow monitoring using asadmin start-callflow-monitoring server and stop using asadmin stop-callfow-monitoring server commands and you are good to go.
    I would believe it should not take you more than couple of hours to code this up. What do I know ? ;-) I implemented some of this :-).
    For details on the callflow layer and mechanism, you can look at the following doc
    https://glassfish.dev.java.net/javaee5/monitoring/callflow/callflow.html . My email is at the bottom - feel free to email me if you have further questions.
    Thanks
    Harpreet

  • JMS QUEUE Problems

    I have an ear that contains 2 Jar (for example JAR1.jar and JAR2.jar).
    JAR1 contains the MessageDrivenBean EJB1.
    JAR2 contains 2 Stateful EJBs: (for example EJB2 and EJB3).
    On webserver there is an JMS Queue called JMSQUEUE.
    The behaviour of my system are:
    When arrive an message on JMSQUEUE the EJB1 get this message.
    I'd like that when a particular external event occurs, the EJB1 stops to process the messages in the JMSQUEUE and that the continue to store all other messages that arrive.
    I thought to Undeploy the EJB1 but this is not a good solution, because if i do it, i undeploy all ear and all EJBs contained in the ear!
    There is another solution to do this ???
    best reagards
    Simone

    Hi Simone,
    IMHO, a MDB for might not be the best match for this. Anyway, if you want to keep using it here's a workaround:
      void onMessage(Message message) {
        if (!enabled()) {
          // wait a bit to avoid CPU load
          Thread.sleep(10000);
          // rollback the message
          messageDrivenContext.setRollbackOnly(); // or throw a runtime exception
        } else {
          // business code here
      bool enabled() {
        // implement lookup for enabled/disabled condition here
      }If you have any more questions on this, feel free to ask in this thread as I'm watching it ;-)
    Good luck
    Benoit

  • What is a domain class?

    I've looked on google but I can not find the correct answer.
    I have an assignment that says: create a domain class and a DAO to perform the database uptdate.
    What in fact is a domain class?

    jschell wrote:
    Kayaman wrote:
    I haven't heard people talking about DAOs much lately (in relation to Java I mean), since with the latest developments in persistence, you have EJBs pretty much handle the role of data access objects.I don't understand that statement.
    I would associate "EJB" with early J2EE/JEE architecture and as far as questions on this site go there are very few about EJBs (either as a general term or a specific one.) That has been replaced by POJO/Hibernate/JPA as general conversational topics.
    And DAO as Data Access Object doesn't show up as much as any of those but does show up more than EJB.I guess what I meant was having session beans in general handle the data accessing. Of course that's not true for everything. A lot has changed in these 10 or so years I've been involved with Java.
    My perspective is also a bit skewed due to some of the projects I'm involved in. For example we have one project that has been around for several years and it started out with EJB2 tech. Now it uses both EJB2 and EJB3 thanks to a "creative" emulation layer.
    Probably Spring and Struts2 and their friends have taken away the questions that once were about the EJBs. Which is just as well in my opinion.

  • Difference between ejb2.1 and ejb3.0

    i want to know the difference between ejb previos version and new version ejb3.0.in ejb 3.0 the deployment descriptor is optional how is possible?

    http://www.javaworld.com/javaworld/jw-08-2005/jw-0815-ejb3.html

  • EJB3 & Patterns: Transfer Objects

    EJB3 Entities look really nice, but I have a couple of slightly related questions...
    Now that our entities are also POJOs, do we need the TO pattern all that much?
    With EJB2 I would have the heavy entity/session beans create light POJO TOs to pass trough the session beans on to the client, this would decouple the clients from the entity beans and if we refactored the entities the clients wouldn't need to know as long as we didn't refactor the POJO TOs.
    With EJB3, the entity beans are also POJOs when they leave the container... thus I don't have to write two sets of classes... but I lose the decoupling...
    I'm not entirely sure I wanted the decoupling all that much for most of the time... and I suppose if we do refactor, I can just keep the former EJB3 Entity/POJO TO as a POJO TO and generate it from the now refactored EJB3 entities... but I'll still have the annotations in the class (unless I strip them... which means recompile the client) so now I have TOs which were EJB3 Entities and are still annotated as such, but which are not being used as such anymore... sounds like a mess!
    And now for the more specific question:
    @Entity
    class Customer {
      private List<Project> projects;
      @OneToMany
      public List<Project> getProjects() { /* ... */ }
    @Entity
    class Project {
      private Customer customer;
      private List<Task> tasks;
      private boolean active;
      @ManyToOne
      public Customer getCustomer() { /* ... */ }
      @OneToMany
      public List<Task> getTasks () { /* ... */ }
      public boolean isActive() { /* ... */ }
    @Entity
    class Task {
      private Project project;
      @ManyToOne
      public Project getProject() { /* ... */ }
    }Now in the above situation, customers have 100s to 1000s of projects each with 10s to 100s of tasks... i.e. the projects are not exactly light objects in and of themselves. (note: i've refactored the object names into a more easily identified problem domain)
    I want to pass a customer object to the client app...
    in some situations the client app does not need to know all the past projects of the customer, only the active ones
    in other cases the client app needs to know nothing about projects (active or not)
    in other cases the client app needs to know only the project names...
    Question: (obviously we'll use LAZY fetching) what's going to happen to my customer entity when I detach it to use it as a TO?
    Will it only have those child objects that I accessed before detaching? Or will it have the potentially megabytes of data for all the inactive projects and all their tasks? My guess is that it depends on the container... and it looks like I'm back to having building TOs in order to guarantee good performance across container vendors
    Or have I got it all wrong?
    Do I just have to have three getClient methods in my CustomerRepositoryBean...
      public Customer findCustomer(...) /* before we detach, recurse all the projects and their associated tasks in the customer to ensure it's all been fetched */
      public Customer findCustomerWithActiveProjectNamesOnly(...) /* before we detach, recurse all active projects, but only access the project name field of the projects */
      public Customer findCustomerWithoutProjectDetail(...) /* detach without accessing the projects */

    OK, I'm not the only person thinking that DTOs are note so necessary anymore with EJB3...
    http://www.jroller.com/page/raghukodali?entry=dto_an_antipattern_in_ejb
    But I'm wondering if I have a case for them with my code sample...

  • How to use ejb2.0 in Jdeveloper 10.1.3

    Hi,
    I am developing a application with the following cofigurations
    EJB2.0 Session Beans
    toplink
    jdk1.4
    JDeveloper 10.1.3
    Oracle AS 10.1.2
    I have done the toplink mapping with the database tables as POJO's.
    Now, when I try to create session bean (EJB2.0) as a business component and selected the check box (Generate Session Facade methods) but the wizard doesn't prompts for the methods to be exposed, however the wizard prompts for methods when i use EJB3.0.
    please clarify on this.
    Thanks & Regards
    Vimalan Balan

    If I'm not mistaken we add the automatic creation of session facade EJB for TopLink/JPA in 10.1.3 - and we only did this for EJB 3.0 Session Beans.
    Given all the improvements and simplifications that EJB 3.0 brings over EJB 2.0 maybe you should consider switching your development to use EJB 3.0.
    Note that you can configure an OC4J 10.1.3 to run under OAS 10.1.2 and thus get EJB 3.0 support in 10.1.2.
    More info here:
    http://download.oracle.com/docs/cd/B32110_01/core.1013/b32196/reconfig.htm#BABIEHFI

  • Swing + JGoodies, EJB3 / Hibernate - Design question...

    Hi,
    Forgive me if I screw up the terminology here.. I'm pretty new to J2EE and Swing development. I'm developing a Swing based application to replace a paper process. It's basically a long form that gets submitted to a server where it is reviewed and in some cases sent back to the user for corrections. I'm having trouble figuring out a good implementation for the data tier.
    The prototype that I've developed makes extensive use of the JGoodies framework (Forms, Binding, Validation). The domain model is basically a bunch of POJO's. For each object there is a separate validator object which has a a validate() method that returns a ValidationResult object. On the Swing side, there is a Model object for each POJO/Validator which listens for changes to the result of validate(). The GUI class attaches to the model and updates the GUI to reflect results of the validation. Basically the result is that if you don't fill out a required field, the field's background color changes and you get a list of reasons why you aren't allowed to submit the form at the bottom of the page. What you type in the field is synchronized with the data object on key release or focus changes (not sure yet).
    Pretty much all of this functionality rests upon the domain model calling 'firePropertyChange' in the setXYZ() functions. This solution seems to work when the client uses Hibernate to persist the objects directly to the DB Server, but I'm wondering if/how it could work if we decided to use EJB3 Entity Beans for storing the data instead of Hibernate (primarily because we don't want to leave our DB server's port open on the firewall).
    From what I've gathered, under EJB3 the POJO's that I'm currently using on the client side (which call 'firePropertyChange') would end up on the server. I am assuming that the 'firePropertyChange' functionality would be broken. When the client binds to the Entity Bean, the server would cause the creation of a new object with simple getters and setters based on the interface on the server side. I assume that this code would be generated for me automatically and I wouldn't be able to get the 'firePropertyChange' functionality back. In other words, the binding between the GUI and the POJO would be lost, along with the automatic validation.
    Is this still possible? Was it ever? Was it possible with EJB2 using the Home objects? Should I just stick with Hibernate and let the clients access the DB server directly? Does anyone have any idea what I'm talking about? The only possibility I could think of was to create another layer of java objects and bind the matching properties between the EJB3 entity bean and the model beans that I already have, but this results in an additional class per form element.
    Thanks,
    Scott

    Hi,
    Forgive me if I screw up the terminology here.. I'm
    pretty new to J2EE and Swing development. I'm
    developing a Swing based application to replace a
    paper process. It's basically a long form that gets
    submitted to a server where it is reviewed and in
    some cases sent back to the user for corrections. I'm
    having trouble figuring out a good implementation for
    the data tier.I'm not familiar with JGoodies. Just browsing their Web site I think they're targeting desktop app, not client/server over a network. firePropertyChange assumes that sender and receiver are both running in the same address space, not on two different hosts on the internet.
    The prototype that I've developed makes extensive use
    of the JGoodies framework (Forms, Binding,
    Validation). The domain model is basically a bunch of
    POJO's. For each object there is a separate validator
    object which has a a validate() method that returns a
    ValidationResult object. On the Swing side, there is
    a Model object for each POJO/Validator which listens
    for changes to the result of validate(). The GUI
    class attaches to the model and updates the GUI to
    reflect results of the validation. Basically the
    result is that if you don't fill out a required
    field, the field's background color changes and you
    get a list of reasons why you aren't allowed to
    submit the form at the bottom of the page. What you
    type in the field is synchronized with the data
    object on key release or focus changes (not sure
    yet).Standard data validation stuff. So far, so good.
    Pretty much all of this functionality rests upon the
    domain model calling 'firePropertyChange' in the
    setXYZ() functions. This solution seems to work when
    the client uses Hibernate to persist the objects
    directly to the DB Server, but I'm wondering if/how
    it could work if we decided to use EJB3 Entity Beans
    for storing the data instead of Hibernate (primarily
    because we don't want to leave our DB server's port
    open on the firewall).I'd say you most certainly do not want to leave that port open on the firewall. The successful functioning of your "firePropertyChange" has nothing at all to do with the choice between Hibernate and EJB3. Neither of them knows or cares.
    From what I've gathered, under EJB3 the POJO's that
    I'm currently using on the client side (which call
    'firePropertyChange') would end up on the server. I
    am assuming that the 'firePropertyChange'
    functionality would be broken. It means that your firePropertyChange would have to have JNDI lookups to find the EJB proxy.
    When the client binds
    to the Entity Bean, the server would cause the
    creation of a new object with simple getters and
    setters based on the interface on the server side. I
    assume that this code would be generated for me
    automatically and I wouldn't be able to get the
    'firePropertyChange' functionality back. In other
    words, the binding between the GUI and the POJO would
    be lost, along with the automatic validation.No, but I'm not sure that you want to do things this way.
    Is this still possible? Was it ever? Was it possible
    with EJB2 using the Home objects? Should I just stick
    with Hibernate and let the clients access the DB
    server directly? Does anyone have any idea what I'm
    talking about? Do you know what you're talking about? 8)
    The only possibility I could think of
    was to create another layer of java objects and bind
    the matching properties between the EJB3 entity bean
    and the model beans that I already have, but this
    results in an additional class per form element.
    Thanks,
    ScottYou definitely want the app server and the database to be on the same side as the firewall. The EJB app tier will stand between the UI and the database. That way you can do validation and, perhaps more importantly, authentication and authorization.
    You don't say whether this is an intranet (clients and servers inside the firewall) or Internet application (clients outside the firewall). If it's the latter, you'll have a very hard time indeed continuing with Swing. If you go with a web-based UI (JSPs and servlets), you eliminate the problem of getting through the firewall, but you take on the added complexity of a web tier, an app tier, and a persistence tier.
    Why EJBs? You're using Hibernate and POJOs - good choice. Why not ditch EJBs altogether and go with Spring instead? You can use Spring MVC for your web tier and Bob's your uncle.
    %

  • Junior needs help in EJB3 - Hibernate

    Hi all,...
    i am hoping some of you can help me with providing me some additional information. I am going to do my first project what i'm not planning to do with JDBC. this time i want to use either Hibernate or EJB3.
    after reading tons of articles about these 2 techniques i still dont know what the exact difference is. i have NEVER worked with EJB's (v2) so i have never experienced that is slow, difficult etc.
    i read that hibernate is fast, easy, and good for smaller projects. and i know that EJB 2 is something i should not use because its hard to learn, i have to do a lot of unnecessary files, etc...
    but with EJB3, i only hear "its almost the same is hibernate". but what is different then, and when should i use what?
    I hope someone can give me some information about this...
    Thanks

    Eh, EJBs and Hibernate are two entirely different
    things, mostly... one's for designing
    modular/distributed enterprise applications, the
    other one's a persistency framework. EJBs do come
    with some persistency stuff, but iff DB access is all
    you want, using EJBs makes no sense at all.although hibernate was the inspiration for EJB3's entity bean replacement, and indeed isn't hibernate3 pretty much an implementation of EJB3 persistence? close enough for jboss to use it as it's EJB3 persistence impl, anyway. I think that's what he's probably getting at
    @OP: it might be worth you using EJB2.1 and entity beans for this, if it's just a pet project or an exercise. nobody uses EJB entity beans any more, but it's worth using them once, just so you can talk in interviews about why they're A Bad Thing &#8482;. don't bother with BMP, that's just a layer of extra work over JDBC. go for CMP, just for the experience. you might want a copy of XDoclet, too, though :-)

  • How to write complex queries in ejb2.0

    Hi ,
    i want to write query for search option since query depend on options choosen by user so the query is created dynamically i.e search params(table colums) may differ
    .Hence i cant use ejb-ql ..... can i use hibernate if yes how can i configure ejb to use hibernate ... else is there any other way
    this is related to ejb2.o ,....... i cant upgrade to ejb3.0

    just as u write it in normal reports u can do the same in smartforms but it is suggested tht i u havve a custom print program do it thr and pass it thru interface
    кu03B1ятu03B9к

  • Identifying EJB3 Application

    hi,
    how can i differenciate an EJB3 and EJB2 Applications without seeing the source code?
    regards,
    panneer

    Check the version number <ejb-jar> element or check the doctype at the start of the the ejb-jar.xml deployment descriptor. This file is located in the META-INF folder in the EJB's jar. If you have an EAR file, unpack the EJB jar file(s) first.
    If there is no ejb-jar.xml file packed with in the jar, assume that you have an EJB3 application.

  • EJB3 - where to perform JMS JNDI lookups?

    Hi, I was reading about how the WebLogic jms wrappers work at:
    http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jms/j2ee.html
    and noticed this section:
    "The JNDI lookups of the Connection Factory and Destination objects can be expensive in terms of performance. This is particularly true if the Destination object points to a Foreign JMS Destination MBean, and therefore, is a lookup on a non-local JNDI provider.". I am using Sonic MQ as my foreign JMS Provider hence this is of particular interest to me.
    The document recommends caching these lookups in the ejbCreate() method of an EJB. I'm new to EJB3 but notice there is no concept of an ejbCreate() method there so where should I cache the lookups and how do I ensure they get re-looked up in the case of a connection failure?
    Many thanks
    Mandy

    Thanks very much Tom, this helps a lot. I think my confusion lay in the fact that this document talks about caching the JNDI lookups in the ejbCreate and gives the example PoolTestBean.java which uses EJB2 style code. I've made your recommended changes to my code, would you mind just casting your eye over to see if looks ok? I have chosen to cache on create of the bean rather than on first invocation as I want clients to fail on startup rather than during their processing.
    Sorry about code layout, not sure how to use HTML in posts to make it verbatim..
    @Stateless
    @TransactionAttribute(NEVER)
    //@ExcludeDefaultInterceptors
    public class ServiceWrapperBean implements ServiceWrapper {
         // injected resources
         @Resource
         private SessionContext sctx; // inject the bean context
         @Resource(name = "sonicConnectionFactory", mappedName = "sonic.connFactory", shareable = true)
         private ConnectionFactory connectionFactory;
         @Resource(name = "LegacyAccessIn", mappedName = "queue/LegacyIn", shareable = true)
         private Destination sendQueue;
         public void sendMessage(String msg) {
              if (connectionFactory == null)
                   connectionFactory = (javax.jms.ConnectionFactory) sctx
                             .lookup("sonicConnectionFactory");
              if (sendQueue == null)
                   sendQueue = (javax.jms.Destination) sctx.lookup("LegacyAccessIn");
              if (msg == null)
                   throw new IllegalArgumentException("object cannot be null!");
              Connection con = null;
              Session session = null;
              MessageProducer sender = null;
              try {
                   con = connectionFactory.createConnection();
                   session = con.createSession(true, Session.AUTO_ACKNOWLEDGE);
                   sender = session.createProducer(null);
                   Message message = session.createTextMessage("do stuff");
                   sender.send(sendQueue, message);
              } catch (JMSException e) {
                   // Invalidate the JNDI objects if there is a failure
                   // this is necessary because the destination object
                   // may become invalid if the destination server has
                   // been shut down
                   connectionFactory = null;
                   sendQueue = null;
                   throw new RuntimeException(e);
              } finally {
                   if (con != null) {
                        try {
                             // Return JMS resources to the resource reference pool for later re-use.
                             // Closing a connection automatically also closes its sessions, etc.
                             con.close(); // also closes other objects
                        } catch (JMSException je) {
                             // ignore
         }

  • What Web frame work to go with EJB3?

    Our coming new project dictates EJB so we plan to use EJB3. But what web frame work is best to go with EJB3? We are currently using Struts1 and EJB2 in our existing project.
    We narrowed down to Struts 1, Struts 2, JSF, and Spring MVC. Since EJB 3 is new to us, we don't know which one is best for EJB 3 integration. Anyone can share their experience? Thanks.

    I suggest you seam framefork with richfaces components, this framefork integrates JSF + EJB and based on MVC of coarse, so that framework gives you great flexibility to write good application
    for jsf UI components you can see this [http://livedemo.exadel.com/richfaces-demo/richfaces/actionparam.jsf|http://livedemo.exadel.com/richfaces-demo/richfaces/actionparam.jsf]
    and for seam framework [http://seamframework.org/|http://seamframework.org/]

Maybe you are looking for

  • CALCULATION IN HEADER FIELD?

    friends... i have designed a form z_pm_common..which i have copied from standard.pm_common. i have made some changes to the layout. now at the header i have a field : DURATION OF JOB  :&AFVGD-ARBEI& &AFVGD-ARBEH& AFVGD-ARBEI IS WORK DURATION.I.E 6.3

  • Deploying Jabber on PC and MAC for BE-6K

    Hi, i ask your help to clarify if i can deploy using BE6K jabber softclient o PC and MAC for a customer that doesn't want to synchronize its user DB with CUCM, or for example does not have one. I am asking because looking at the deploying guide for J

  • How to use CVS to fetch the repository

    hello. I want to use cvs to fetch some codes from j3d.org. When I do "cvs -d CVSROOT=:pserver:anonymous@cvs. j3d.org:/home/cvs/j3d/cvsroot checkout code " in cvs directory, I get error message "connection refused". what's wrong ? could some one help

  • Photos coming out too light. switching from easyphotoprint/winxp to EX/win7x64

    I have a customer that switched from a Windows XP system with i9900 using EasyPhotoPrint  to a Win7x64 system with easy photo print EX. as far as i can tell all settings are default on each piece of software. same paper etc. Way too many photos will

  • Text (varchar2(320)) to a number

    Hi, May I know how to convert text (varchar2(350)) to a number in an sql...?