BC4J DAOs vs. Local Entity Beans

We are beginning a brand new project and trying to evaluate the costs/benefits of using BC4J entity objects versus local entity beans for our persistence needs.
I've read the "Simplifying J2EE and EJB Development with BC4J" white paper including the "How Does EJB 2.0 Change the Picture?" section, but that seems to have been written at a time when EJB 2.0 support was a rarity.
I'd like to get some feedback from people who have had experience with both. We are basically starting this application from scratch, although we have relational tables from our legacy C++ application that will serve as the basis for the Java object model. So what would we gain/lose by using entity objects?
I must admit, I'm leaning toward using entity beans over a vendor-specific persistence framework, but if there are compelling reasons to choose entity objects (besides those mentioned in the white paper), I'd like to hear them. Please speak slowly, as I'm new to BC4J. :)
Thanks for your time.

I've read the "Simplifying J2EE and EJB Development with BC4J" white paper including the "How Does EJB 2.0 Change the Picture?" section, but that seems to have been written at a time when EJB 2.0 support was a rarity.IMO there's no change.
What Sun doesn't tell you in the specs, but is much talked about on theserverside.com and in most
anti-patterns threads, and in the up coming book J2EE Anti-Patterns; EJB Entities are basically
broke with no solution. Reason: EjbStore() can throw an exception due to DB constraint violation
after the business method returns. This drives the scenario where all business integrity is
forced up into the middle tiers (EJB and business mediator tiers). etc etc ... EJB Entities are
useful for the 5% to 1% of a business model and application that is transactional IMO.
I.E. 95%++ of most apps/web sites are read only. Why use a heavy and expensive transactional
component for reading rows from a DB to be displayed on an Inventory screen? The only reason
to do this is if you have stock in Sun and your appserver vendor or want your project to last
forever or get canceled. -- Seriously, do your home work, using Entities as your persistance
tier mediator, for the 95% of your project that's read only, and for reports which involve
joins, select criteria etc etc will be a serious problem to just code and even bigger problem
to be responsive and scalable.
Do this experiment: implement a report that joins several tables, selects on where criteria,
orders by some attribute in EJB Entity bean technology. Seriously try to code this solution.
Hint: spray water on your appserver box since it'll almost explode. :)
Then try: do the same report in SQL. One SQL statement usually will do it and it's all in the
DB. The data returned to the middle tier is ready for JSP formating.
Try another EJB experiment: implement a finder based on criteria that returns a Collection.
Do the same in SQL: time the perf difference.
Hint: Maybe you're getting the picture, that EJB Entity 2.0 --> 10.0 what-ever, never wrote into
the specs any means for joins, or high perf finders based on criteria.
My opinion and experience: EJB Entity is good for one portion of a project if that; the single
part that's transactional (usually the shopping cart or similar). All other data access needs
to be through a DAO tier that's SQL based. With BC4J you get transactional support too, so
why bother with EJB, except to be wrapped by SLSB's for remotability from the client.
I'd like to get some feedback from people who have had experience with both. We are basically starting this application from scratch, although we have relational tables from our legacy C++ application that will serve as the basis for the Java object model. So what would we gain/lose by using entity objects? I'm at the end of phase one of a medium scale BC4J project which was initiated after scrapping
a Sun Blueprint J2EE 1.2 architecture for the above reasons, plus the unmentioned time to market
issue. We found hand coding the Sun architecture to be 400% slower, if you don't hit any of the
above mentioned bumps in the road. We never got to reports, which would have been imposible without
custom DAOs.
I must admit, I'm leaning toward using entity beans over a vendor-specific persistence framework, but if there are compelling reasons to choose entity objects (besides those mentioned in the white paper), I'd like to hear them. Please speak slowly, as I'm new to BC4J. :)You're not the first to ask this question nor the last. Sun's happy talk in the face of their
king has great cloths sell job to fend off .net will take more than just J2EE Anti-patterns books
to displell. Try the reports and finders experiements in EJB 2.0. You'll no doubt learn alot
and read more news group posts in the process.
Heck, you might even discover that 903 oc4j's CMR and EQL can instantiate 1000's of Entity beans,
JNDI entries, return a Collection of handles, your client get the ValueObjects and build a report
in less than a minute and 100's of customers can do this simultanteously. __NOT__ :)
Cheers,
curt

Similar Messages

  • Business components mapped to EJB 2.0 local entity beans

    Hi ,
    I read about the new feature in JDev 903 that is "Creating business components mapped to EJB 2.0 local entity beans". but I am not able to find any documentation on it.can anyone provide me any link or help on this topic.
    Thanx,
    Prasoon

    Prasoon -
    For JDeveloper 10g, version 9.0.5.1, there is information on this topic located in the help:
    Building J2EE Applications >
    Working with the Business Tier >
    Developing Enterprise JavaBean Applications >
    Using Business Component Entity Facades
    Hope this helps,
    Lynn
    Java Tools Team

  • Calling Local Entity Beans from another Application

    Hi,
    I packaged all my Local entity Beans in 1 single Application (APP1.EAR).
    I then I have another Application (APP2.EAR) which is made of Session Beans which require access to the APP1 application.
    I'm using this code to achieve this:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "manager");
    env.put(Context.PROVIDER_URL, "ormi://<host>/APP1");
    context = new InitialContext(env);
    ... (BeanLocalHome)context.lookup("java:comp/env/ejb/BeanLocal");
    I get the Following Exception:
    javax.naming.NameNotFoundException: java:comp/env/ejb/BeanLocal not found
    1) is there any problem with this code?
    2) can local interfaces be accessed by another Application (or can they be accessed only by the same application) ?
    Regards.
    giuseppe.

    Hi ,
    thank you for your answer.
    I'm still in trouble:
    these are the steps:
    App1.jar entity beans.
    App2.jar Session bean.
    I embedded the App1.jar into the App2.ear
    dir :
    App1.jar
    App2.jar
    application.xml (added the App1.jar)
    then I added this in the ejb-jar.xml deployment descriptor for App2.jar
    <ejb-link>../App1.jar#BeanName</ejb-link>
    for each entity bean.
    But I still get :
    javax.naming.NameNotFoundException: java:comp/env/ejb/BeanNameLocal not found
    java.lang.Object com.evermind.server.ApplicationContext.lookup(java.lang.String, boolean)
    ApplicationContext.java:110
    java.lang.Object com.evermind.server.ApplicationContext.lookup(java.lang.String)
    ApplicationContext.java:66
    java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
    What am I missing ??
    Thanks.
    giuseppe.

  • Cannot lookup local entity bean through JNDI

    I have an local entity bean with local-jndi-name as "ejb/Address". After deployed
    to WL 8.1 server and tested on the Admin page, I got:
    The EJB Address has not been tested successfully. There was a problem determining
    the JNDI Name of the given bean.
    When looking up this bean by:
    Object ref2 = context.lookup("ejb/Address");
    or
    Object ref2 = context.lookup("java:comp/env/ejb/Address");
    or
    Object ref2 = context.lookup("/ejb/Address");
    I got the same error:
    javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException:
    remaining name: /app/ejb/iitga_ejb.jar#Address/local-home
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
    -- Failed initializing bean access.
    Has anyone successfully deployed/lookuped local entity beans in WL 8.1 server?
    Thanks,

    Does the ejb have a jndi binding?
    "Henry Niu" <[email protected]> wrote:
    >
    I have an local entity bean with local-jndi-name as "ejb/Address". After
    deployed
    to WL 8.1 server and tested on the Admin page, I got:
    The EJB Address has not been tested successfully. There was a problem
    determining
    the JNDI Name of the given bean.
    When looking up this bean by:
    Object ref2 = context.lookup("ejb/Address");
    or
    Object ref2 = context.lookup("java:comp/env/ejb/Address");
    or
    Object ref2 = context.lookup("/ejb/Address");
    I got the same error:
    javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException:
    remaining name: /app/ejb/iitga_ejb.jar#Address/local-home
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
    -- Failed initializing bean access.
    Has anyone successfully deployed/lookuped local entity beans in WL 8.1
    server?
    Thanks,

  • User threads and local entity beans

    I have started a background thread to handle transferring large files via ftp. This thread needs to be able to access the entity beans via a local interface (to log its progress). I have started oc4j with -userThreads (debugger -Doc4j.userThreads=true) and I get the NameNotFoundException when trying to find the beans via a local home interface.
    The code looks like this:
    <code>
    InitialContext context = new InitialContext();
    JobLocalHome home = (JobLocalHome)context.lookup(JOB);
    JobLocal job = home.findByPrimaryKey("java:comp/env/ejb/JobLocal");
    </code>
    This code works perfectly when called from the context of another bean, but not from the background thread. Can background threads use local interfaces? Or do I have to have remote interfaces on these beans just to allow the background thread to operate?

    Hi - Resolved this one
    The Target for the compiler was set wrong in Jdeveloper!!!
    Set to "default" resolved this
    Tks

  • Exposing local entity beans to web tier?

    Hello all,
    I have a question concerning basic design issues with EJB and the JSP presentation
    layer. Currently, I have designed a system using all local component interfaces
    of EJB 2.0. I currently have the following architecture in place:
    EJB --> Servlets (WebWork Actions) --> JSP
    I'm utilizing the session facade design pattern where the business logic in encapsulated
    in session beans, which internally access the entity beans, etc. However, I am
    doing something of the following:
    sessionBean.getUserAccounts() which returns a Collection of actual UserAcountLocal's.
    I then am passing this collection off to the JSP just to cycle through each entity
    bean and display the data via its getXXX() methods. No modifications to the entity
    beans are being done directly in the Actions/JSPs, rather they are modified through
    methods of the session beans. Now I know that there is the concept of DTO (Data
    transfer objects), which send the data from the particular entity bean to a regular
    java bean for presentation. I know that DTO's increase performance if one is using
    remote interfaces, because there is less network traffic that occurs via that
    transport method. However, I know that WebLogic performs excellent caching of
    entity beans, so that multiple invocations of get() methods on entity beans will
    not make a trip to the database each and every time the get() method is called.
    So, my question is: Is it "safe" to continue with the current way I am designing/coding
    the system? I just find it a bit tedious to create value objects for each and
    every entity bean, if I know that I will not be calling setXXX() methods from
    within the presentation layer. Also, with EJB 2.0 and the introduction of local
    component interfaces, it seems that issues regarding limiting the amount of network
    traffic don't seem to be so relevant. Any suggestions/tips are appreciated. :-)
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669

    use dtos
    the main reason is that if you call a getXXX() method on a local or remote
    interface from your servlet then that bean is retrieved again (as the
    servlet is outside the transaction involved in the initial retrieval)
    For example if you retrieve 100 users and want to display them in a html
    table with the user id, first name and lastname then there end up being more
    than 300 SQL statements executed (this is unless your ejbs are readonly)
    If you have a tool (like sql server profiler) that traces sql statements i
    recommend you use it to see the staggering amount of sql statements that are
    being executed by your current code - then DTOs will look much more
    appealing (it worked for me) :).
    I would also recommend using dtos when performing updates. Basically work
    towards your servlets never directly accessing anything entity bean related.
    Some people extend this further and have the DTO as the single argument in
    the create method of an entity bean - I havent done this yet myself but it
    looks like a good idea to me.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    >
    Hello all,
    I have a question concerning basic design issues with EJB and the JSPpresentation
    layer. Currently, I have designed a system using all local componentinterfaces
    of EJB 2.0. I currently have the following architecture in place:
    EJB --> Servlets (WebWork Actions) --> JSP
    I'm utilizing the session facade design pattern where the business logicin encapsulated
    in session beans, which internally access the entity beans, etc. However,I am
    doing something of the following:
    sessionBean.getUserAccounts() which returns a Collection of actualUserAcountLocal's.
    I then am passing this collection off to the JSP just to cycle througheach entity
    bean and display the data via its getXXX() methods. No modifications tothe entity
    beans are being done directly in the Actions/JSPs, rather they aremodified through
    methods of the session beans. Now I know that there is the concept of DTO(Data
    transfer objects), which send the data from the particular entity bean toa regular
    java bean for presentation. I know that DTO's increase performance if oneis using
    remote interfaces, because there is less network traffic that occurs viathat
    transport method. However, I know that WebLogic performs excellent cachingof
    entity beans, so that multiple invocations of get() methods on entitybeans will
    not make a trip to the database each and every time the get() method iscalled.
    So, my question is: Is it "safe" to continue with the current way I amdesigning/coding
    the system? I just find it a bit tedious to create value objects for eachand
    every entity bean, if I know that I will not be calling setXXX() methodsfrom
    within the presentation layer. Also, with EJB 2.0 and the introduction oflocal
    component interfaces, it seems that issues regarding limiting the amountof network
    traffic don't seem to be so relevant. Any suggestions/tips areappreciated. :-)
    >
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669

  • How to persist local entity reference?

    I had a remote entity bean A hold a reference to a remote entity bean B's handle. Now I change them to local entity beans. But Local entity bean doesn't support Handle and I found local entity stub is not even Serializable (WebSphere5.0). How do I persist local entity bean B's reference? This is kind of non-container managed relationship. Why ejb2.0 spec doesn't support local entity Handle? How do you do non-container managed relationship without handle?

    "I had a remote entity bean A hold a reference to a remote entity bean B's handle."
    You hold a reference; as in an instance variable? If so, how did you use the handle? What did you do with the reference when the entity was stored or passivated?
    "Now I change them to local entity beans. But Local entity bean doesn't support Handle... Why ejb2.0 spec doesn't support local entity Handle? "
    Handle objects are intended to assist with holding for long-lived references to remote objects by avoiding the potential problems associated with holding a reference directly to the remote object. Since there are no concerns with respect to working remotely, Local objects do not need a Handle. Just hold reference to the Local directly, like you would any other object.
    "...and I found local entity stub is not even Serializable."
    Well of course not, it's not a remote object. One of the main points driving the use of local interfaces is to limit access to components. Hence only components within the same JVM as the Local can access it.
    "How do I persist local entity bean B's reference?"
    What do you mean by "persist"? Were you actually storing the Handle object into the database?! If so, then I see why you wanted a serializable Local Handle.

  • How to use same transaction when calling CMP entity beans and  DAO (JDBC)

    We are currently using Weblogic 8.1 SP2 with an Oracle 10g database (using XA thin and non-XA drivers).
    We have a session bean that invokes an entity bean and a DAO (data access object pattern) in order to add data in 2 separate tables (account and history). Rows are added to the first (account) table using a CMP Entity bean while inserts are done in the 2nd (history) table using a DAO. Here is some pseudo code:
    addHistorySessionBean (trans-attribute="Required")
    begin
    Step #1 - call addAccountEntityBean (trans- attribute="Required")
    Step #2 - call addHistoryDAO (get datasource, connection)
    end
    The 2nd table (history) has a foreign key constraint to ensure that the corresponding key exists in the first (account) table. Unfortunately, DAO inserts on the 2nd (history) table fail with a foreign key constraint violation (INTEGRITY CONSTRAINT VIOLATION - PARENT KEY NOT FOUND!) since they cannot see the row added to the 1st (account) table in step #1 by the CMP entity bean.
    How does one ensure that all this is done in a single transaction ? It appears that the app server creates two seperate transactions (one for the session bean facade and the entity bean and a 2nd transaction (when we retrieve a connection using the same data source JNDI name) for the DAO.
    A post on server side suggested using a "<resource-ref>" in the session bean to tie the two potentially separate transactions together, but that does not work for us. However, I am not sure if we are doing that correctly. After we define the resource ref in the session facade bean, do we use the resource ref "name" attribute to lookup the datasource or do we still lookup the datasource by JNDI name ? Do we need to define the resource-ref tag in the entity bean also ?
    Does Weblogic allow using a single transaction for this type of a scenario ? How does one specify within Weblogic that the same transaction should be utilized by the entity bean and any subsequent DAOs?
    People have also suggested that we defer constraint checking until the transaction(s) are committed but that sounds like a work acount without addressing this issue. Would postponing the constraint checking in Oracle cause any additional overhead ?
    Any suggestions with specific examples or documentation on how to address this issue will be gratefully appreciated.

    Thanks for your suggestion. Unfortunately, this does not work since it appears that there are 2 separate transactions going on here. One, the original one initiated by the session bean and used by the entity bean and the other initiated by the DAO. Any other ideas appreciated.
    Hi,
    Try setting the delay-database-inserts tag to
    ejbCreate in RDBMS descriptor file.
    http://bernal/stage/wls/docs81/ejb/DDreference-cmp-jar
    .html#1113981
    vasanthi ramesh

  • Regarding ENTITY bean local interfaces

    Hi all,
    I have a component session bean - containing a number of service methods for creating, retrieving, updating & deleting instances of a related entity bean. This session bean is used by another session facade bean, which invokes the various service methods in some sequence to complete a major task.
    In the component session bean, the retireve methods return the local interface of the entity bean - on which it operates. The update methods accespt local interfaces of entity bean which can be directly updated.
    My question is : Is it a right approach to pass the entity bean instances between method calls.
    Thanks in advance,
    Baskar

    Your pointers regarding pt 2 was nice. Thanks.
    This being my first J2ee design, I'am just collecting as much information as possible to stay confident.
    Later, I started thinking a bit more regarding pt 1.
    Where, I decided using individual session beans for different components(representing unique functionalities).
    i.e,, I'am just thinking, should I use individual session beans for each of these different components.
    What if I use standard java classes - implementing pre-defined interfaces for each of these components & use the components through these interfaces in session facade.
    Now, I'll be using entity bean creates/retrieves/updates/deletes from inside normal java classes.
    I thought, this would obviate the need for JNDI lookups - each time I want to use the components in my session facade.
    But, I'am not sure of where this will impact..As far as I can visualize, this seems to be normal. Please share ...your thoughts regarding this. (something regarding transactions ??)

  • EJB entity beans and BC4J

    I have looked at BC4J and it looks good. Buy my question is that isn't this frame work in direct conflict with EJB entity beans. I know lot of stuff that is there in BC4J should have been in EJB enitiy beans, but as a developer why should I go with BC4J and not the standard EJB stuff considering the fact that BC4J is properietery to Oracle?Any thoughts?

    Vimal,
    Without going into exhaustive detail here, I would like to recommend that you take a look at the BC4J Technical White Paper available from the JDeveloper page on OTN (in the 3.0 Technical Information section):
    http://technet.oracle.com/products/jdev/info/techwp20/wp.html
    Amoung other things to note, BC4J is based on pure Java, and is what we consider a 'white box', meaning, you as a developer have complete control over what is going on. You can extend any of the code generated to customize it.
    Primarily though, the major benefit of BC4J is that we have taken care of most of the complicated communication code for you. Communication between the client and the data server, transaction handling, row locking, etc are already written for you. You just use, extend, customize what we have provided.
    In addition, BC4J allows you flexibility in your deployment environment decision. Regardless of where and how you deploy your BC4J Application Module, the client is unchanged.
    Those are the key advantages. Again, for more details, I would take a look at the white paper to see if it more fully addresses your questions.

  • Plaese  HELP  JAVA DEVELOPER DAO and ENTITY BEAN

    WHEN DO WE USE ENTITY BEAN INSTEAD OF DAO

    Generally DAO's are used with Stateless Session beans where the transactions may involve in different query executions. We go for Entity beans for persistence.

  • CMP Entity beans using local interfaces

    Why CMP entity beans with CMR relation ship using local interfaces only?
    Why we should not use remote interface to get the CMR field relationship?
    Pls give me the solutions

    "Local interfaces provide the foundation for container-managed relationships among entity beans and session beans. The bean uses the local interface to maintain its references to other beans. For example, an entity bean uses its local interfaces to maintain relationships to other entity beans. Using local interfaces, beans can also expose their state and use pass-by-reference to pass their state between related bean instances. "
    http://java.sun.com/developer/technicalArticles/ebeans/EJB20CMP/

  • DAO and entity bean

    I have an entity bean which has a lot of gets and set methods. i am calling all the methods in a DAO. The DAO Recognizes all the old methods but not the last one, i dont understand why a single get Set is not being recognized.

    Your question is not very clear. Could you tell the problem in details?

  • Do I need to Create Primary Key Class for Entity beans with Local interface

    Do I need to Create Primary Key Class for Entity beans with Local interface?
    I have created my entity bean with the wizard in Sun One Studio and it does not create a primary key class for you.
    I thought that the primary key class was required. My key is made up of only one field.
    Anyone know the answer.
    Jim

    u dont need to create a primary key class for a entity bean.if ur table's primary key feild(int ,float) is a built in or primitive data type,then u dont need one.But if ur table has a primary key field which is non primitive (for example StudentID,ItemID etc)then u have to create a primary key class.
    hope this helps :-)

  • Problems deploying entity beans with local interfaces on Jboss?

    I'm trying to deploy a simple entity bean using local interfaces on Jboss 3.2.1 and I obtain the following exception:
    19:08:51,875 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.2.2
    Warning: The entity bean class must not be defined as abstract.
    19:08:51,875 WARN [verifier] EJB spec violation:
    Bean : UsersEJB
    Section: 9.4.7.1
    Warning: The primkey-field element must name a public field in the bean implemen
    tation class.
    Any idea?
    Thanks,
    Marco

    I guess you are missing <cmp-version>2.x</cmp-version> for your first warning and <primkey-field>primary key field </primkey-field> for you second warning in your ejb-jar.xml

Maybe you are looking for

  • Why are some apps not shown as installed?

    Are apps that were purchased prior to App Store, in my case iWork apps, not going to show as installed on the MAS? Is it only apps installed from MAS that will appear as installed? Olly

  • Folder with Question Mark when booting?

    Twice during the past 4 times booting my MacPro, I have received a folder icon with a question mark in it. I turned off the mac and restarted it and it rebooted. Why is it doing this? Thanks.

  • I want to mount / partition Read-Only !

    I have Arch installed on my Acer Aspire One... and it works great on this little machine! The Acer One has no hard disk, but uses SSD, so to reduce writes to disk i use EXT2, I have my /home on a separate SD card, and I mounted log and temp directori

  • Mistaken personal domain name, how do I change it?

    I am using iWeb iLife 08, and have my own .mac account. I am trying to set up my own personal web name for my iWeb account, which I have purchased through GoDaddy. I entered the name, or what I thought was the correct name (wrong by 1 letter) and sub

  • How to stop the selection of an empty table?

    Hello , everyone. I created a JTable : tableView : tableView.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tableView.getSelectionModel().addListSelectionListener(this); tableView is a empty table , that is to say , tableView.getRo