当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: Chapter 6. Creating a CMP Entit
 

 

    摘要: chapter 8. creating web clientsthis chapter describes how to create web clients in the client tier/presentation tier to access or otherwise communicate with the business tier. servlets and jsp pages ......
 ·使用ejb3.o简化ejb开发(一)    »显示摘要«
    摘要: 使用ejb3.o简化ejb开发 原著:debu panda我们引入ejb来构造分布式的组件。它诞生之时是为了解决所有corba的问题和复杂性。经历过几次重要的版本更新和增加许多特性之后,ejb已经成为了j2ee的核心。在早期,很多开发人员沉迷于ejb甚至在没有任何意义的情况下在他们的工程中使用ejb。而当他们发现所使用的工程并没有质的变化后,谴责ejb成了一种趋势。开发ejb从来没有变得简单甚至......


Tutorial for building J2EE Applications using JBOSS and ECLIPSE (6)
上一页   ...

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.


...   下一页
 ·java规则——开发篇    »显示摘要«
    摘要: 本文介绍的java规则的说明分为3个主要级别,本篇抛弃了平时开发中很少遇到的情况,那些用得比较少的以后再高级篇里面出现。并有六个有用的国际软件开发重要注意的有关string的问题,遵守了这些规则可以提高程序的效率、使代码又更好的可读性等。(1) 如果有jdbc连接没有关掉的话,需要在"finally"方法中关掉如果数据库连接失败或者是没有释放连接,看上去无关紧要。但是其他的用......
» 本期热门文章:
· 热门栏目:
» 相关精选文章
» 其它相关:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE