锁定老帖子 主题:JDeveloper 11g
该帖已经被评为良好帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-07-06
1. ADF 实践<o:p></o:p><o:p> </o:p> 1.1. 简言ADF实践__JDeveloper<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>与JDeveloper<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>日前,本人分别在JDeveloper<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>和JDeveloper<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>上做了个ADF数据库应用的小DEMO.感觉<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>和<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>存在着比较大的差异.首先: <st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>在原有功能上增加了对Ajax功能的支持,可以说功能更加强大,但在实际使用中,我觉得<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>的使用性更好,更易于开发.或许是因为<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>新增的功能吧,未能深入了解到.以下几点,是我在做此DEMO过程中遇到的问题. <o:p> </o:p> 1.2. <st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>与<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>问题简要汇总1.TopLink表关系影射生成POJO对象问题USERS表结构: CREATE TABLE USERS ( USER_ID NUMBER(8,0) NOT NULL, USER_ROLE VARCHAR2(10) NOT NULL, EMAIL VARCHAR2(50) NOT NULL, FIRST_NAME VARCHAR2(30) NOT NULL, LAST_NAME VARCHAR2(30) NOT NULL, STREET_ADDRESS VARCHAR2(40) NOT NULL, CITY VARCHAR2(30) NOT NULL, STATE_PROVINCE VARCHAR2(25), POSTAL_CODE VARCHAR2(12), COUNTRY_ID CHAR(2) ) NOLOGGING INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645); <o:p> </o:p> <v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id="_x0000_i1025" style="WIDTH: 314.25pt; HEIGHT: 269.25pt" type="#_x0000_t75"><v:imagedata o:title="T1" src="file:///C:\DOCUME~1\BeanSoft\LOCALS~1\Temp\msohtml1\01\clip_image001.gif"></v:imagedata></v:shape> 在JDeveloper <st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中: 其通过TopLink可生成类Users.java 表字段:userId生成属性: private Integer userId; 而在JDeveloper <st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中 : 竟然是: private BigDecimal userId;<o:p></o:p> 2.Create Object-Relational Map我在用TopLink从数据表生成对象POJO时, 在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中,选择DataModel(表示了应用的数据模型,应用系统通过DataModel来执行数据访问操作。) –- New -- Business Tier – TopLink – Java Objects from Tables. 如下图:可以通过Connection下拉列表选择我们之前建立的数据库链接。 <v:shape id="_x0000_i1026" style="WIDTH: 452.25pt; HEIGHT: 306pt" type="#_x0000_t75"><v:imagedata o:title="1" src="file:///C:\DOCUME~1\BeanSoft\LOCALS~1\Temp\msohtml1\01\clip_image002.png"></v:imagedata></v:shape> <o:p> </o:p> 在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中,我们通过此操作,在Connection: 下拉列表中是选不到之前建立的数据库链接的. 需要我们在Database Navigator面板中选中我们建立的数据库链接,将其拖动到 Project面板中的DataModel上。这时我们才能使用之前建立的数据库链接。 个人认为: 在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中,建立的Connection,将为所有的工程共同使用。 而在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中,数据库链接独立于所有工程,需手动将其应用于现有工程。 <v:shape id="_x0000_i1027" style="WIDTH: 484.5pt; HEIGHT: 404.25pt" type="#_x0000_t75"><v:imagedata o:title="2" src="file:///C:\DOCUME~1\BeanSoft\LOCALS~1\Temp\msohtml1\01\clip_image004.png"></v:imagedata></v:shape> <o:p> </o:p> <o:p> </o:p>后表之间关系的生成机制通过TopLink由表影射生成POJO对象.表之间的关系,在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>和<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中,TopLink的处理机制有所不同: <st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中: private List expertiseAreasCollection; private List serviceRequestsCollection; private Integer prodId; private String name; private String image; private String description; <v:shape id="_x0000_i1028" style="WIDTH: 229.5pt; HEIGHT: 301.5pt" type="#_x0000_t75"><v:imagedata o:title="2" src="file:///C:\DOCUME~1\BeanSoft\LOCALS~1\Temp\msohtml1\01\clip_image006.png"></v:imagedata></v:shape> <o:p> </o:p> <o:p> </o:p> 在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中: <v:shape id="_x0000_i1029" style="WIDTH: 224.25pt; HEIGHT: 425.25pt" type="#_x0000_t75"><v:imagedata o:title="3333333333333333" src="file:///C:\DOCUME~1\BeanSoft\LOCALS~1\Temp\msohtml1\01\clip_image008.png"></v:imagedata></v:shape> 关于Products.java,其中生成的属性为: private Collection expertiseAreasCollection; private Collection serviceRequestsCollection; private BigDecimal prodId; private String name; private String image; private String description; <o:p> </o:p> 注: <st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中,关于表之间影射关系(1对多,多对1,等)生成的集合类为List<o:p></o:p> <st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中,生成的集合类为Connection.<o:p></o:p> List是链表,Collection是集合,比List抽象层次更高.List可以按照索引单独访问一组对象, Collection可以用foreach循环访问其中的元素,<o:p></o:p> List执行效率应该比Collection更高,实际中使用List的情况应该更多.<o:p></o:p> 不知道为什么<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>生成的属性均为Collection?有待于进一步研究. <o:p></o:p> 代码生成机制,代码格式化效果在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中,代码格式化效果更好,比<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>智能,不知<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>与<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>代码格式化使用的是何插件?如何控制代码生成规则? 例,在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中, Public Integer getNextLineItem(){ } 方法中的{},在输入完{}后,光标停留在大括号之间,按回车键,代码格式自动整理好,如上.另起一行对其. 在<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中, 回车后,下行代码空出两个字符. Public Integer getNextLineItem(){ } 以上可见,<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中的效果更佳. Defining Page Flow and Navigation将<st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>和<st1:chmetcnv w:st="on" unitname="g" sourcevalue="11" hasspace="False" negative="False" numbertype="1" tcsc="0">11g</st1:chmetcnv>中,关于页面Diagram和page创建过程稍有不同.此差别来源于所用视图层开发控件的变化<st1:chmetcnv w:st="on" unitname="g" sourcevalue=".1" hasspace="False" negative="False" numbertype="1" tcsc="0">.10g</st1:chmetcnv>中视图层开发的组件库主要为: ADF Faces Components; ADF Faces HTML; JSF Core; JSF HTML. 如: <st1:chmetcnv w:st="on" unitname="g" sourcevalue="10" hasspace="False" negative="False" numbertype="1" tcsc="0">10g</st1:chmetcnv>中,在Components组件面板中选择ADF Faces Core时,可以使用控件: PanelPage, 如图1: SRDemoTemplate.jspx
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-07-09
前两年用过,文档少啊
|
|
返回顶楼 | |
浏览 7081 次