Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Java Sample Questions ›› EJB Java Sample Questions

Java Technical Sample Questions : EJB Sample Questions

  1. Can a Session Bean be defined without ejbCreate() method?

    Answer: The ejbCreate() methods is part of the bean's lifecycle, so, the compiler will not return an error because there is no ejbCreate() method.However, the J2EE spec is explicit: the home interface of a Stateless Session Bean must have a single create() method with no arguments, while the session bean class must contain exactly one ejbCreate() method, also without arguments.Stateful Session Beans can have arguments (more than one create method) stateful beans can contain multiple ejbCreate() as long as they match with the home interface definition.You need a reference to your EJBObject to startwith.For that Sun insists on putting a method for creating that reference (create method in the home interface).The EJBObject does matter here.Not the actual bean.

  2. Is it possible to share an HttpSession between a JSP and EJB? What happens when any one changes a value in the HttpSession from inside an EJB?

    Answer: You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.This has to be consider as "passed-by-value", that means that it's read-only in the EJB.If anything is altered from inside the EJB, it won't be reflected back to the HttpSession of the Servlet Container.The "pass-by-reference" can be used between EJBs Remote Interfaces, as they are remote references.While it IS possible to pass an HttpSession as a parameter to an EJB object, it is considered to be "bad practice (1)" in terms of object oriented design.This is because you are creating an unnecessary coupling between back-end objects (ejbs) and front-end objects (HttpSession).Create a higher-level of abstraction for your ejb's api.Rather than passing the whole, fat, HttpSession (which carries with it a bunch of http semantics), create a class that acts as a value object (or structure) that holds all the data you need to pass back and forth between front-end/back-end.Consider the case where your ejb needs to support a non-http-based client.This higher level of abstraction will be flexible enough to support it.(1) Core J2EE design patterns (2001)

  3. Is there any way to read values from an entity bean without locking it for the rest of the transaction ( transactions)? We have a key-value map bean which deadlocks during some concurrent reads.Isolation levels seem to affect the database only, and we need to work within a transaction.

    Answer: The only thing that comes to (my) mind is that you could write a 'group accessor' - a method that returns a single object containing all of your entity bean's attributes (or all interesting attributes).This method could then be placed in a 'Requires New' transaction.This way, the current transaction would be suspended for the duration of the call to the entity bean and the entity bean's fetch/operate/commit cycle will be in a separate transaction and any locks should be released immediately.Depending on the granularity of what you need to pull out of the map, the group accessor might be overkill.

  4. What is the difference between a "Coarse Grained" Entity Bean and a "Fine Grained" Entity Bean?

    Answer: A 'fine grained' entity bean is pretty much directly mapped to one relational table, in third normal form.A 'coarse grained' entity bean is larger and more complex, either because its attributes include values or lists from other tables, or because it 'owns' one or more sets of dependent objects.Note that the coarse grained bean might be mapped to a single table or flat file, but that single table is going to be pretty ugly, with data copied from other tables, repeated field groups, columns that are dependent on non-key fields, etc.Fine grained entities are generally considered a liability in large systems because they will tend to increase the load on several of the EJB server's subsystems (there will be more objects exported through the distribution layer, more objects participating in transactions, more skeletons in memory, more EJB Objects in memory, etc.)

  5. What is EJBDoclet?

    Answer: EJBDoclet is an open source JavaDoc doclet that generates a lot of the EJB related source files from custom JavaDoc comments tags embedded in the EJB source file.

  6. Are enterprise beans allowed to use Thread.sleep()?

    Answer: Enterprise beans make use of the services provided by the EJB container, such as life-cycle management.To avoid conflicts with these services, enterprise beans are restricted from performing certain operations: Managing or synchronizing threads

  7. Is it possible to write two EJB's that share the same Remote and Home interfaces, and have different bean classes? if so, what are the advantages/disadvantages?

    Answer: It's certainly possible.In fact, there's an example that ships with the Inprise Application Server of an Account interface with separate implementations for CheckingAccount and SavingsAccount, one of which was CMP and one of which was BMP.

  8. Is it possible to specify multiple JNDI names when deploying an EJB?

    Answer: No.To achieve this you have to deploy your EJB multiple times each specifying a different JNDI name.

  9. Is there any way to force an Entity Bean to store itself to the db? I don't wanna wait for the container to update the db, I want to do it NOW! Is it possible?

    Answer: Specify the transaction attribute of the bean as RequiresNew.Then as per section of the EJB v 1.1 spec EJB container automatically starts a new transaction before the method call.The container also performs the commit protocol before the method result is sent to the client.

  10. I am developing a BMP Entity bean.I have noticed that whenever the create method is invoked, the ejbLoad() and the ejbStore() methods are also invoked.I feel that once my database insert is done, having to do a select and update SQL queries is major this behavior typical of all EJB containers? Is there any way to suppress these invocations?

    Answer: This is the default behaviour for EJB.The specification states that ejbLoad() will be called before every transaction and ejbStore() after every transaction.Each Vendor has optimizations, which are proprietary for this scenario.

« Previous || Next »

EJB Sample Question Number : 1-10| 11-20| 21-30| 31-40| 41-50| 51-60| 61-70| 71-80| 81-89
Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.