go to package explorer > expand mystore (project) node > select src, right click and a menu will pop up.
enter the package name au.com.tusc.cmp, the bean name item and select the bean type as container manged entity as shown below. 【程序编程相关:Struts中tiles的使用】
on the pop up menu > new > lomboz ejb creation wizard. 【推荐阅读:spring+hibernate开发网站】
go to next and a new screen will pop up as shown below. 【扩展信息:java.net.URLClassLoa】
enter mystoreitem as the schema name.
enter item as the table name.
under persistent fields first enter itemid as the field, with a field type of java.lang.string, itemid as its database column, and varchar for its sql type.
press add .. > it will add this field in fields section, select this new field > press make primary key.
similarly, add all the rest of the fields of the items table as shown below.add .. field: supplierid, field type: java.lang.string, database column: supplierid, sql type: varchar. add .. field: description, field type: java.lang.string, database column: description, sql type: varchar. add .. field: quantity, field type: java.lang.integer, database column: quantity, sql type: integer. add .. field: price, field type: java.lang.float, database column: price, sql type: decimal.after adding all these fields, press finish.
this will create a package named au.com.tusc.cmp under src, and itembean will be be created within that package as shown below.
note: in comparison with our earlier bmp entity beans (customer & manager), more tags have been generated at class level. note also that cmp doesnt require a data access object (dao) interface, as communication between database and bean is controlled by the container.
lets first the generate ejb classes and then we will examine these tags.go to node itembean under au.com.tusc.cmp > lombozj2ee > add ejb to module > select mystoremgr > ok.
go to mystoremgr node > lombozj2ee > generate ejb classes.
note: all these steps are covered in previous chapters (chapters 3 and 1) in detail, so please refer to these if you have any queries.
now, lets see what files have been generated by xdoclet.
as shown below, the files generated are nearly the same as for bmp, except there are no primary key or dao classes, and there is now itemcmp which extends the itembean class. the remainder are the same as for bmp entity beans.
now, lets examine these new tags, some of which have been covered in previous chapters.
@ejb.bean tag provides information about the ejb. it is the one compulsory tag for all ejbs.@ejb.persistence tag is being used at two levels, at class level and method level. at class level it provides information about the persistence of a cmp entity bean, that is which database table this bean is going to interact with, which will provide that persistence. at method level it provides information about the mapping of the beans persistent attributes to columns in that database table.... 下一页