Java Bean:
Nothing but a pojo ( plain old java object) with only difference in naming and use of methods. For every field to be catered to, there needs to be a set,get method. Eg setFirstName, getFirstName.
What this helps out is in file level persistence. As the methods are clearly named, the Java framework can save files (in a standard format) from the objects (persistence). This thus enables uses of beans as good interface and UI objects as they can store 'properties' very well. This can be likened to the VB programming paradigm of dragging buttons into forms and filling the correct set of properties. This is possibly the reason why Java Beans are used a plug and play type situations (acting as a facade) and in similar way in UI design via drag-and-drop.
Enterprise Jave Bean
The enterprise Java Bean essentially extens this concept to the enterprise level, taking persistence to the Database.
Types of beans
1. Session
2. Entity
3. MDB
Session beans are used via the session facade design pattern. They provide two interfaces:Home and remote. The home is used to locate the bean ? while the remote is the actual interface exposed.The way they manage persistence is using ORM technology like Hibernate.
Hibernate
In this the elements of the class to be ORMized are mapped to correspinding sql table columns and defined in a mapping file. Hibernate also provides for basic transaction control, in the form of database rollback in case of non-commit.
There is a standard sessionfactory class to be used to get the handle of a 'service' object. This service object can be used to load and save the parameters in a hibernate session. eg:
1.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment