|
61) Can the primary key in the entity bean
be a Java primitive type such as
int?
The primary key can't be a primitive type--use
the primitive wrapper classes, instead. For example, you can use
java.lang.Integer as the primary key class, but not int (it has to be a class,
not a primitive).
62) How do I map a Date/Time field to an
Oracle database with CMP?
[Question continues: (I have written a wrapper
class with the help of java.util.GregorianCalendar but it doesn't store time
in Oracle database, whereas it stores Date without any problem.)]
Use the java.sql.Timestamp field to store your
Date/Time in your entity bean, and then declare the corresponding field as
'Date' type in the Oracle database and it will work fine. You will have the
"date" value and the "time" value preserved.
63) What is the difference between a
Server, a Container, and a
Connector?
To keep things (very) simple:
An EJB server is an application, usually a
product such as BEA WebLogic, that provides (or should provide) for concurrent
client connections and manages system resources such as threads, processes,
memory, database connections, network connections, etc.
An EJB container runs inside (or within) an
EJB server, and provides deployed EJB beans with transaction and security
management, etc. The EJB container insulates an EJB bean from the specifics of
an underlying EJB server by providing a simple, standard API between the EJB
bean and its container.
(Note: The EJB 1.1 specification makes it
clear that it does not architect the interface between the EJB container and
EJB server, which it says it left up to the vendor on how to split the
implementation of the required functionality between the two. Thus there is no
clear distinction between server and container.)
A Connector provides the ability for any
Enterprise Information System (EIS) to plug into any EJB server which supports
the Connector architecture.
64) What is "clustering" in
EJB?
Clustering refers to the ability of multiple
load-balanced web servers to share session and entity data. It is a major
feature of web application servers. Standardized support for clustering was
one of the primary motivations behind the EJB spec.
Clustering also applies to Servlet containers
sharing HttpSession data (similar to EJB Session Beans).
65) What is "hot deployment" in
WebLogic?
"Hot Deployment" in weblogic is the act of
deploying, re-depolying, and un-deploying EJBs while the server is still
running (you don't have to shutdown the server to deploy an EJB).
66) Can I specify specific WHERE clauses
for a find method in a CMP Entity
Bean?
The EJB query language is totally vendor
specific in EJB1.1. It is being standardized in 1.2.
Yes, you can specify the where clause for a
find method. This is the example for EJB's deployed on weblogic:
findBigAccounts(double balanceGreaterThan): "(> balance $balanceGreaterThan)"
where balance maps to some field in the table.
67) When using a stateful session bean with
an idle timeout set, how can the bean receive notification from the container
that it is being removed due to
timeout?
[Question continues: ? (Through some tests, it
looks like none of the standard EJB callback methods are called when a
stateful session bean is removed due to idle-timeout.)]
According to the spec, ejbRemove need not (or
must not) be called in this case. ejbPassivate is simply the Wrong Thing to be
called (the bean is transitioning to the 'does not exist' state, not the
'passive' state).
The EJB 1.1. spec says in section 6.6.3 Missed
ejbRemove Calls:
The application using the session bean should
provide some clean up mechanism to periodically clean up the unreleased
resources.
For example, if a shopping cart component is
implemented as a session bean, and the session bean stores the shopping cart
content in a database, the application should provide a program that runs
periodically and removes “abandoned” shopping carts from the
database.
Probably not the answer you're looking for,
especially if you allocate some other resource (a Message Queue, for example)
that you need to release. Although, if you're using a resource, you really
should be getting it when you need it (via JNDI) and returning it back
to the pool right away.
68) I have created a remote reference to an
EJB in FirstServlet. Can I put the reference in a servlet session and use that
in SecondServlet?
Yes.
The EJB client (in this case your servlet)
acquires a remote reference to an EJB from the Home Interface; that reference
is serializable and can be passed from servlet to servlet.
If it is a session bean, then the EJB server
will consider your web client's servlet session to correspond to a single EJB
session, which is usually (but not always) what you want.
69) What is the difference between a
Component Transaction Monitor (CTM) and an Application Server?
A Component Transaction Monitor (CTM)
is an application server that uses a server-side component model. Since a CTM
is a Transaction Processing monitor (TP), it is expected to provide
services for managing transactions, security, and concurrency. In addition,
CTMs also facilitate distributed object architectures and provide facilities
for object persistence. In short, a CTM is a specific type of application
server.
70) How can I call one EJB from inside of
another EJB?
Just do it!
EJBs can be clients of other EJBs. It just
works. Really. Use JNDI to locate the Home Interface of the other bean, then
acquire an instance reference, and so forth.
|
|
|
Bookmark This Page :
|
|
|
|
|
|
|
|
|
|
|
|
java6 ejb3 jsf hibernate eclipse ajax groovy spring seam java struts webservice j2me guice java5 jca tapestry soa linux ria |