> What does persistence
> mean actually?
Most of the times , it means persisting Java objects to a relational database.
Given the "impedance mismatch" between tabular structures in the db and java objects , there are several technologies which aim to facilitate persistence by providing some sort of obj-relational (O/R) mapping. EJB is one of them.
In EJB 2x, Entity Beans were a (poor) solution to the persistence problem.
In EJB 3.0, Entity Beans have become POJOs with annotations, with the O/R mapping largely inspired by Hibernate.
Your reply was informative but my doubt is:-
The object still persists if there is some database crashes or application server crashes?
I meant suppose if we are using JBOSS and MySql, EJB objects will persist even after Server crash? What is the main use of EJB's?
If possible please explain.
> Your reply was informative but my doubt is:-
> The object still persists if there is some database
> crashes or application server crashes?
> I meant suppose if we are using JBOSS and MySql, EJB
> objects will persist even after Server crash?
The EJB will survive if it was persisted prior to the crash.
> What is
> the main use of EJB's?
To ease the development of distributed / "network aware" applications.
> You mean to say prior to MySql crash or JBoss
> application crash?
Think about it. The EJB can survive if MySQL crashes and JBoss is still running. An EJB can also survive a crash of the application server even if it hasn't been persisted (if the application server is clustered and replicated). The EJB will survive if it was persisted prior to a crash of both the application server and database.
kaj
> Ya now I am saying the proper doubt which I had,
> How can the object survive when there is no
> Application server running? Will that be stored in
> some containers so that they can be recoverd later?
> If so where will that container be?
What? The EJB will "resurrected" when the application server is restarted.
Kaj
Think about it. The EJB can survive if MySQL crashes and JBoss is still running. An EJB can also survive a crash of the application server even if it hasn't been persisted (if the application server is clustered and replicated). The EJB will survive if it was persisted prior to a crash of both the application server and database.
kaj
You had replied above saying "An EJB can also survive a crash of the application server even if it hasn't been persisted, An EJB can also survive a crash of the application server even if it hasn't been persisted "
So asked how EJB's can survive after the server crash?
My view was EJB's can only be survived if there is any database crash...
> Ya now I am saying the proper doubt which I had,
> How can the object survive when there is no
> Application server running? Will that be stored in
> some containers so that they can be recoverd later?
> If so where will that container be?
Obviously a Java object can't exist outside of a JVM, but the data from that object can be stored to a database or file, and the object reconstructed from that data on subsequent runs.
Persistance managers automate that process so you can ask for an object on the basis of some kind of key or search values and that the object will be built if there isn't one already cached.
Further they keep track of these persistant objects and dump them back to the database when they are found to have changed.
Think about it. The EJB can survive if MySQL crashes and JBoss is still running. An EJB can also survive a crash of the application server even if it hasn't been persisted (if the application server is clustered and replicated). The EJB will survive if it was persisted prior to a crash of both the application server and database.
kaj
You had replied above saying "An EJB can also survive a crash of the application server even if it hasn't been persisted, An EJB can also survive a crash of the application server even if it hasn't been persisted "
So asked how EJB's can survive after the server crash?
My view was EJB's can only be survived if there is any database crash...
Email this Topic
> You had replied above saying "An EJB can also survive
> a crash of the application server even if it hasn't
> been persisted, An EJB can also survive a crash of
> the application server even if it hasn't been
> persisted "
> So asked how EJB's can survive after the server
> crash?
It will survive if the state of the EJB has been replicated to a another application server. Some application servers can be configured to work in a cluster which can handle fail over.
Kaj
> Your reply was informative but my doubt is:-
> The object still persists if there is some database
> crashes or application server crashes?
> I meant suppose if we are using JBOSS and MySql, EJB
> objects will persist even after Server crash? What is
> the main use of EJB's?
> If possible please explain.
There are 4 types of EJBs.
1) - 2) Session beans (stateful and stateless) are not meant to survive a server crash, since they're basically in-memory objects.
3) Message-driven beans are removed when the server crashes, but since messages are not lost (QoS), they can be re-delivered when the server restarts and the EJB container gets a bean from the pool again.
4) Entity beans are "views" of the database (an object wrapper around the db data), so it's understandable that they can be "resurrected" after a server crash. When the server is restarted, the container can always find a bean instance to represent persistent data.
Of course, you will lose any data that wasnt committed prior to a crash. This is where you should start looking into clustering .
If your database also crashes, then all the saved changes are also lost unless you have some recovery mechanism to get the data back.
The main (and most successful) use of EJB is not persistence per say, but rather handling business logic in a transactional distributed environment. And that involves mostly stateless session beans.
> I meant how persistence and EJB concepts are related.
They are one model for relatiing Java objects with relational databases. Sure there are non-entity beans, but persistent entity beans are the main point of the excercise.
Instead of doing SQL yourself via JDBC you use an Object-Relational Mapper (ORM). This hides the database activity from the programmer and allows the application programmer (at least) to work entirely with objects, without being concerned how those objects are stored on the database. Ideally you can completely re-think your database design without affecting your application programs (I don't know if anyone ever does this).
> Instead of doing SQL yourself via JDBC you use an
> Object-Relational Mapper (ORM). This hides the
> database activity from the programmer and allows the
> application programmer (at least) to work entirely
> with objects, without being concerned how those
> objects are stored on the database. Ideally you can
> completely re-think your database design without
> affecting your application programs (I don't know if
> anyone ever does this).
That is also true for non EJB applications.
> > Ideally you
> can
> > completely re-think your database design without
> > affecting your application programs (I don't know
> if
> > anyone ever does this).
>
> That is also true for non EJB applications.
Sure, if you use another ORM, like Hibernate, for example. Personally I get the impression this stuff is heavilly overused. It could make sense on very large projects where there are complex divisions of labour. For one or two man projects I'm inclined to doubt it's worth doing.
It's the kind of thing that appeals to management rather than technical people. Gives a greater illusion of control.