Entity Beans

Entity beings? No, beans. Learn to write 'em, connect 'em to a database and access 'em via their cousin, the session bean.

EJB is an impressive technology, doing far more than the simple object-relational mappers Alzabo and DODS. From my experience, working with EJB is more of a managerial and logistical headache than a technical one. Learning EJB is a good idea for all web application developers; it's clear that this standard is making serious inroads in the industry, and many serious applications will be built using EJB in the future. Having certified open-source implementations will make it even easier for programmers to try out EJB, and I encourage Sun to move in this direction as soon as possible.

Next month, we'll switch gears to begin looking at Zope, a very different type of web application framework written mostly in Python. Zope has become quite popular in the last few years and is often seen as the killer app that will bring Python to the forefront of programming languages. We'll take a look at Zope and start to examine how we can use it to write our own applications.


Reuven M. Lerner owns a small consulting firm specializing in web and internet technologies. He lives with his wife Shira and daughter Atara Margalit in Modi'in, Israel. You can reach him at reuven@lerner.co.il or on the ATF home page, www.lerner.co.il/atf.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


jagruti's picture

can anyone help to write code for jsp entering bookname and displaying authorname from schema using ejb strut
how to connect jsp to session bean and further to entity bean and all configuration of jbosstomcat4.1

Re: At the Forge: Entity Beans

Anonymous's picture

Experienced database programmers know that primary keys should be hidden from view,

I don't agree with this. How would we identify the entities then?
The primary key is the set of attributes that identifies the entity, and this means that it has to be visibale.

and most databases have a way to automate this; PostgreSQL's SERIAL type, MySQL's AUTO INCREMENT and Oracle's sequences are common solutions to this problem.

Those are only artificial primary keys. You can run into few problems when you wnat to use them.
For example you can't be sure what key belongs to the entity you have currently written into the table, because if the primary key is given by the database. If the written row has no primary key except the assigned one you can't even select by the attributes to get the ID, because you can get multiple rows as the response and then the bet is only way to decide. If you have multiple concurent writes it gets even worse.

Unfortunately, there is no easy way to use such automatically generated primary keys within EJB.

UID object from java.rmi.server can give you primary key.
It is a bit strange (out of sequence) but unique, and that is what counts.

Re: At the Forge: Entity Beans

Anonymous's picture

Where to get the database schema for this example ? thanks