<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>JavaEye论坛最新讨论</title>
    <description>JavaEye论坛最新讨论 - Java编程，Ruby编程，微软.net，AJAX，敏捷软件开发，综合软件技术</description>
    <link>http://www.javaeye.com</link>
    <language>UTF-8</language>
    <copyright>Copyright 2003-2008, JavaEye.com</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>JavaEye - 做最棒的软件开发交流社区</generator>
          <item>
        <title>解释一下，为什么需要接口而不直接实现类。</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://lonelybug.javaeye.com">lonelybug</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/248494" style="color:red;">http://www.javaeye.com/topic/248494</a>&nbsp;
          发表时间: 2008年10月01日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          看了这里的一些帖子和很多地方的帖子，很多人都在问为什么非要interface或者abstract class，然后还要在写一个实现类，而其实，我就市要做一个很简单的功能！？<br /><br />对，如果你制作一个简单的功能，我同意你可以直接使用spring hibernate等框架来写，他们本身的好处也是干这个的。<br /><br />但是，中国人有句老话，叫做杞人忧天，很多的时候，你有没有内心问自己，这个系统，我设计的，如果老板要改动，我可以在很短的时间内做到改变么？<br /><br />当你问自己这个问题的时候，你就已经把直接写实现类的做法怀疑了。<br /><br />面向接口的原则，不是只出现在程序员或者说IT界，接口设计是人类对一个问题或者一个物体的概括理解能力的表现。我们日常生活中处处有接口。<br /><br />在我作一个简单的说明之前，我要补充以下，系统框架中，除了层的概念，还有一个叫做boundary,每一个layer（层）是由不同的boundary（box）组成。<br /><br />举例一二三，比如，简单的说，发电厂就是实现类(implementation class)，每个发电厂都是独立的boundary，而发电厂就是统称为一个layer，也许还不明白，比如，我们平时说，发电厂，没人关心你家的电来自于那个发电厂，而关心的是你家的插座有没有电，所以三项插座，二项插座至十发电厂给用户的最终接口。发电厂之间也是通过一个特殊的工业接口来互相访问，所以，这也是为什么说，有时候有的发电厂在夏天负担过重，就可以把负担分给其他的电场供应。反过来，如果让老百姓天天关心的是发电厂，而不是插座，那你觉得这样的城市电力设计是不是很糟糕呢？<br /><br />在举个例子，比如果.....，嗯，好，就说汽车，汽车都见过吧，四个轮子，一个方向盘，但是，你们有没有发现，有时候你们的汽车上面的音响系统坏掉或者要升级的时候，只需要取下中间面板上面的那个独立的音响播放器，然后买一个新的，由汽车维修给你们撞上就可以了，不管是飞利浦，boss还是简单的radio的和卡带的，你们从来不会在买一个汽车音响的时候关心他能不能安在汽车上，而是可以完全关心颜色，款式，品牌这些问题上，如果，反过来设计，每一个汽车品牌都直接实现自己的独立设计，不遵循工业接口，那你觉得这样的汽车音响会有很多选择么？<br /><br />最后在举一个我们每天息息相关的例子，门，每天人们通过不同的门，进入或者走出不同的地方，而门就是那个地方或者建筑物的接口，如果说，我们反过来，每个大厦或者建筑物都直接应用自己喜欢的实现进出的方式，那你们觉得每天的生活会不会有点太麻烦？<br /><br />我举例子只是来简单的解释一下，接口不是一个繁琐的过程，而是每个工业，甚至是每天生活中，我们必须应用到的东西，所以，如果看待现在的文明社会用程序员的方式的话，那么就是一种接口世界，现实生活中很多人叫做标准或者协议，由看得见摸得找的，也有看不见摸不着的接口。<br /><br />很多人可能想对我举的例子进行进一步的反驳，其实没有必要，如果你要跟我探讨每一个例子来映射程序中的接口问题，那就是在抬杠，抬杠很浪费时间，所以，我不会跟你探讨例子的问题，那就是个例子，而这个例子是每天确实发生的，使用的。<br /><br />希望能解释明白一点在程序设计中接口编程的优势所在。
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/248494" style="color:red;">已有 <strong>32</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Wed, 01 Oct 2008 23:32:46 +0800</pubDate>
        <link>http://www.javaeye.com/topic/248494</link>
        <guid>http://www.javaeye.com/topic/248494</guid>
      </item>
          <item>
        <title>毕业在即，工作迫在眉睫，大家替我参谋参谋</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://wanday.javaeye.com">wanday</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/248990" style="color:red;">http://www.javaeye.com/topic/248990</a>&nbsp;
          发表时间: 2008年10月05日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          本人某一本学校大四生，目前正在找工作，但是对于自己的定位不是很准，一心是想做Java方面开发的，想去的地方是上海、杭州，因为离我家近，现在主要的问题是不知道自己在技术上究竟算的上一个什么水准，也不知道自己在能去多大规模的公司，然后在薪水的期望上也不知道应该定在一个什么样的水平算合适。所以下面贴一下我的简历，大家帮忙看看！<br /><br /><br /><br />简历：<br /><br />个人简历<br /><br /><br />学历	本科（学士）	外语	英语6级（口语优秀）	<br />联系电话	13787277435	E-mail	amaomiaowdy@163.com	<br />毕业时间	2009年6月	<br />求职意向	Java软件工程师<br />（后略……）<br /><br />以上是简历（中英文），大家指点指点！<br /><br /><span style="color: red">2008年10月6日 更新<br />在看了大家的评价以后，我很仔细的重新修改了简历，如下：</span><br /><br /><br />个人简历<br />	<br />所在专业	网络工程	学&nbsp;&nbsp;&nbsp; 历	本科（学士）	<br />联系电话	13787277435	外&nbsp;&nbsp;&nbsp; 语	英语6级（口语优秀）	<br />E-mail	amaomiaowdy@163.com	毕业时间	2009年6月	<br />求职意向	Java软件工程师<br />教育经历	2005年9月至2009年7月 长沙理工大学网络工程专业（主修软件工程）<br />2007年4月至2007年12月中信Java软件培训中心<br />专业课程	Java程序设计、数据结构、数据库原理、软件工程、C++程序设计、专业英语<br />奖励情况	2005年 网络知识竞赛一等奖、三等奖学金<br />2006年 程序设计大赛二等奖<br />2007年 网页设计大赛二等奖<br />相关证书	2006年 Adobe认证产品专家<br />自我评价	本人性格开朗、幽默，善于交流，兴趣广泛，尤其喜爱唱歌和舞蹈（恰恰跳的不错，但是不喜欢玩游戏），做事有耐心、有责任心（大唐电力系统在后期几乎就只有我一个人在做，但是还是坚持做完了），要做就一定会做完、做好，但是有时有点过于苛求；并且本人可塑性好、学习能力强，喜欢编程、热爱软件事业，能吃苦（曾连续写程序14小时），具有很好的团队领导能力和对事物的宏观把握能力。<br />人生格言：我们是人，人就一定能够想到办法去解决问题！<br />专业能力<br />J2SE：熟悉Swing、JDBC编程，了解Socket、多线程以及反射机制，对面向对象编程有较为深刻的理解；<br />J2EE：能够熟练运用并理解Struts、Struts2、Spring、Hibernate等J2EE开源框架，能够熟练使用XML及其解析技术（SAX、DOM、JDOM），对MVC有较为深刻的理解，熟悉JSP，能够熟练使用JExcel、JFreeChart、JMail等开源解决方案；<br />服 务 器：能够熟练使用Tomcat服务器，对Weblogic有所了解；<br />数 据 库：熟悉SQL，能够熟练使用Oracle 9i、MySql 5.0数据库；<br />开发工具：能够熟练使用Eclipse、Rational Rose、ERwin、Dreamweaver、Photoshop等开发工具；<br />网页相关：熟悉HTML、JavaScript、CSS，能够熟练使用Ajax进行编程；<br />其&nbsp;&nbsp;&nbsp; 他：熟悉UML以及O/R Mapping建模，对Android手机平台开发（基于Java开发）也较为熟悉，对SOA、SaaS、敏捷开发有所了解；<br />实践经验<br />1、	2007年5月-6月 酒店管理程序<br />该程序是一个基于C/S模式的桌面应用系统，结合JDBC、Swing等技术，完成酒店点菜、选桌（包间）、结算以及仓库管理等业务功能，并且酒店前台、厨房以及仓库使用相同的系统以实现管理同步，系统根据登录权限不同提供不同的功能。数据库使用Oracle。<br />在项目组中担任编码人员，并参与数据库设计。<br />2、2007年11月-12月 大唐电力ERP模拟系统（扭亏增盈部分）<br />该系统基于Spring+Struts+Hibernate框架，使用B/S模式，结合JExcel、JFreeChart、JavaScript等技术，完成大唐电力公司各基层电厂的年度先进值、年度目标值、供电煤耗、综合厂用电率、入厂入炉煤热值差等数据的采集、统计、分析、报表生成以及人员管理等功能。<br />采集：这里为了适合用户的习惯，数据记录文件采用Excel，当用户上传了Excel文件以后，系统能够自动分析Excel文件并从中采集数据保存到数据库中；<br />分析：系统能够根据用户选择的选项动态生成三围线、柱状、曲线图，以图形化的方式向用户展示数据分析结果；<br />报表生成：系统能够根据用户选择的数据项生成报表，系统允许用户选择直接打印报表（提供打印预览）或者导出Excel文件；<br />数据库使用Oracle 9i。<br />在项目组中担任组长，并参与软件的架构、数据库设计以及页面设计，并完成数据上传和扭亏增盈分析模块的编码任务。<br />3、2008年1月-2月 1717DL.COM网站V1<br />该网站基于Struts+Hibernate框架，结合使用JMail、Ajax等技术，完成游戏代练信息发布、代练工作室注册、代练工作室后台管理（类似于博客管理）、代练信息竞标、代练任务承接以及相关管理功能。<br />代练信息和工作室注册都需要经过网站管理员审核，审核通过了才能在网站的前端页面上显示出来；工作室注册通过以后，系统会发送一封Email到注册时填写的邮箱以确认注册有效；<br />工作室可以申请开通能够代练的游戏（这是需要付费的，否则该工作室就无法看到该游戏的代练信息），然后等待管理员审核，开通以后就能查看相关的代练信息，这时他们需要以竞价的形式（如果信息发布者已经限定了价格就不需要了）对代练信息进行报价（工作室之间不能互相查看报价以保证公平性），最后由信息发布者根据报价以及工作室的信誉度等相关信息决定游戏代练的承接方。<br />信息发布者以及工作室之间都是相互屏蔽的，无法直接联系，所有的交易活动都必须经过网站管理员才能够进行。<br />数据库使用MySql 5.0。<br />在项目组中担任组长，完成网页设计、数据库设计等任务，并完成网站管理后台以及代练工作室管理后台的编码工作。<br />4、2008年4月 1717DL.COM网站V2（目前在线）<br />使用的技术与V1类似，完成游戏代练进度实时更新、电子产品信息发布、网络服务信息发布、数字卡销售商城等功能。<br />该网站的所有工作均由本人单人完成。<br />5、2008年6月-今 个人开发团队网站<br />该网站基于Struts框架，结合使用JDOM、Ajax等技术，完成技术信息发布、会员注册、视频教程上传下载、专家组、外包信息发布、成功案例展示、后台管理等功能。考虑到网站信息量不大以及资金问题，网站后台不使用数据库，而使用读写XML以及properties文件进行数据持久化。<br />该网站的所有工作均由本人个人完成，主要用来进行团队宣传，目前正在建设中。<br /><br />Resume<br /><br />Major	Network Engineering	Education	Bachelor	<br />Foreign	CET6(Excellent oral English)	Connection	13787277435	<br />Graduation	2009-06	<br />Intention	Java software engineer<br />Education<br />Experience	2005.09~2009.07: Changsha University of Science & Technology(CSUST) in Network Engineering (Mainly in Software Engineering)<br />2007.04~2007.12: Changsha Infosoft Java Training Center<br />Vocational Courses	Java Language Programming、Data Structure、Principle of Database、Software Engineering、C++ Language Programming、Vocational English<br />Rewards	2005: Network knowledge competition&nbsp; First; Scholarship Third<br />2006: Programming competition&nbsp; Second<br />2007: Web page designing competition&nbsp; Second<br />Certificates	2006: Adobe Certified Product Expert(ACPE)<br />About Me	I’m outward and humor, good at communication with others. And I’m wide interest especially singing and dancing (my qia-qia is not bad but don’t like electronic games). I’m patient and responsible (there was almost only me during the end of Datang electricity system but still finished it). If I want to do, I must will do it completely and well although sometimes much too strict. And I have a good learning ability, I like programming and zeal in software career, can bear hard condition (can struggle for 14 hours once), and I possess an excellent ability in the team leading. <br />Life motto: We are human beings, human beings will do be able to find ways to solve problems!<br />IT Skills<br />J2SE: Familiar with AWT, Swing, JDBC programming; Know Socket, Multi-thread and Reflection; Have a deep understanding of Object-oriented programming.<br />J2EE: Can use skillfully and understand the following J2EE framework: Struts, Struts2, Spring and Hibernate; Can use XML and it’s resolving technology skillfully; Have a deep understanding of MVC; Familiar with JSP; Can use the following open-source solutions: JExcel, JFreeChart, JMail and so on.<br />Server: Can use the Tomcat server skillfully; Know Weblogic.<br />Database: Familiar with SQL; Can use Oracle 9i, MySql 5.0 skillfully. <br />Tools: Can use Eclipse, MyEclipse, Rational Rose, Erwin, Dreamweaver, Photoshop skillfully.<br />Web: Familiar with HTML, CSS, JavaScript; Can use Ajax to program skillfully.<br />Other: Familiar with UML and O/R Mapping; Familiar with Android mobile platform (Based on Java programming); Know SOA, SaaS, Extreme programming.<br />Practice Experience<br />1.	2007.05~2007.06&nbsp; Hotel Management System<br />This is a desktop application system based on the C/S model combining with the JDBC technology which can provide menuing, account, storage management and so on functions. And the hotel front, storage, kitchen use the same system to achieve management synchronization. The system will provide different functions to users according to their login. The database we used is Oracle. <br />In the program team, I was a coder and played a role in the database designing.<br />2.	2007.11~2007.12&nbsp; Datang Electricity ERP system (Profit and loss analyzing part)<br />The system use the B/S model combining with JExcel, JFreeChart, JavaScript and some other technologies based on the Struts, Spring and Hibernate frameworks. It can do the following things: colleting, counting, analyzing and reporting the data of the yearly advance, the yearly aim, the electricity-coal contrast and some others from the basic electricity factories of Datang company and also employee management. <br />Data colleting: In order to meet users’ habits, we used excel file to record data. After users uploaded excel files, the system will analyze data files automatic and get data out and save them into database;<br />Analyzing: The system will produce a three-lines or columnar or curve image to show the analyzing result in a graphic form according to what use chose;<br />Reporting: The system will produce a report according to what customer chose, and the system allow customer to print(also preview) the report or get out the report in the excel form.<br />The database is Oracle. <br />I was the captain of the team, and took part in the software conformation designing, database designing and web pages designing. And I also finished the data-upload and the cost-profit analyzing parts.<br />3.	2008.01~2008.02&nbsp; www.1717dl.com V1<br />The web site based on the Struts and Hibernate framework combining with the JMail and Ajax technologies which can provide the following functions: Releasing the game part-time job information, studio registering, studio’s background management (Something like the blog’s background management), bidding of the game part-time job information, getting the game part-time job and some other daily management. <br />The game part-time job information and studio registering needs checking of the administrator, the information will be seen on the web site’s front pages only when they are passed; And the system will send an email to the registered Email box when the studio registering request has passed in order to be sure of the registering.<br />Studios could apply for rights of games that they can play as agent (for this need payment or else they can not see any information), and then waiting for administrator’s checking. If the application is passed, then the studio can browse the information and he can quote for these information in the auction form or needn’t if it did have a price when it was released (Studio can not know others’ quoting for fair). At last, the information releaser will decide the undertaker according to their credit and some other information.<br />Information releasers and studios are all shielded and they can’t connect with each other directly and all the business must pass through administrator.<br />The database we used is MySql 5.0.<br />In the project team, I was the captain. My duty was web pages designing and database designing. And I completed the code of the web site’s background management and the studio’s background management.<br />4.	2008.04&nbsp; www.1717dl.com V2(Online)<br />The technology used is similar with version 1. It can provide the following functions: Real-time updating of the game’s progress, electronic products information releasing, network services information releasing and digital cards sailing. <br />In fact, I did all the jobs of the web site only by myself.<br />5.	2008.06~now&nbsp; Personal disseminating web site<br />This web site is based on the Struts framework combining with JMail, Ajax and JDOM which can provide the following functions: technology message releasing, member registering, video course upload and download, expert information management, success case showing and background management. For the data is not too much and the funding issue, we don’t use a database but instead of reading and writing XML and properties files to keep data. <br />I do all the works of the web site only by myself, mainly for personal team disseminating and it’s building.
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/248990" style="color:red;">已有 <strong>53</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sun, 05 Oct 2008 01:39:13 +0800</pubDate>
        <link>http://www.javaeye.com/topic/248990</link>
        <guid>http://www.javaeye.com/topic/248990</guid>
      </item>
          <item>
        <title>Hibernate查询缓存的一个可靠性问题</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://raymond2006k.javaeye.com">raymond2006k</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249508" style="color:red;">http://www.javaeye.com/topic/249508</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          之前在对项目中Hibernate的缓存性能进行测试时发现的一个问题，不知大家有没有遇到或者是解决办法。<br />&nbsp;&nbsp;&nbsp; 问题是：使用sql query且是多表关联查询，并启用查询缓存时，对关联表修改后，查询缓存未能更新，出现了不正确的查询结果集。<br /><br />&nbsp;&nbsp;&nbsp; 测试场景： <br />&nbsp;&nbsp;&nbsp; 1. 用例：为简单起见，测试中使用了两表关联查询。查询指定角色 (roleCode) 的所有已授权限点 (Perm集合)<br />&nbsp;&nbsp;&nbsp; 2. 库表：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 权限点表(sys_perm )字段： permCode, permName, moduleCode,...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 角色授权表(sys_role_perm )字段： roleCode, permCode, createTime,...<br /><br />&nbsp;&nbsp; 3. 关联查询 <br />(其实仅判断所授权限点编码集合，用Hibernate 关联抓取，就可以解决，并且二级缓存也能很好的控制此问题；即使用 named sql query进行鉴权，也只需查 sys_role_perm表返回 permCode集合。这里返回 perm 集合， 这里主要是为测试关联查询时的cache query问题而举的一个例子)<br /><pre name="code" class="xml">
&lt;!-- 角色拥有的所有已授权限集合 -->
&lt;sql-query name="system.roleperms">
	select  *  from sys_perm t join sys_role_perm o 
    on t.perm_code = o.perm_code 
    where o.role_code = :roleCode 
&lt;/sql-query>
&lt;/class>
</pre><br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 3. 预置数据：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 角色编码： STESTOR， <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 权限点：permCode 组织新增： ORG_ADD<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在 sys_role_perm 表中为 STESTOR 授予 组织管理新增的权限: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (STESTOR,ORG_ADD,2007-3-27 10:34:32)<br /><br />&nbsp;&nbsp;&nbsp; 4. 测试代码：<br />&nbsp;&nbsp;&nbsp;&nbsp; 执行三次doQueryRolePerms 查询功能，在第二次执行完毕时，删除 (STESTOR,ORG_ADD) 这条授权，观察第三次查询是否重新去数据库取数。<br /><br /><pre name="code" class="java">
for (int i = 0; i &lt; 3; i++) {
   System.out.println(" Execute No. " + i + " ********************");
   List perms = (List)perm.doQueryRolePerms("STESTOR"); 		
   System.out.println("(" + i +")result size:"  + perms.size()  );

   if(i % 2 == 1) 
    rolePerm.doRemoveByVO(rolePermVO1); //删除授权：STESTOR, ORG_ADD	
}
</pre><br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp; 5. 执行分析：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 第1，2次执行，由于有预置授权，因此 result size： 1；<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 第3次执行查询，由于删除了唯一的授权，那么 result size： 0。<br /><br />&nbsp;&nbsp;&nbsp; <strong>6. 实际结果：</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <pre name="code" class="java">

 Execute No. 0 ********************
2008-10-06 17:26:26,406 [DEBUG](AbstractBatcher.java,324) - select  this.PERMCODE as  PERM1_0_,  this.MODULECODE as  MODULE2_15_0_,  this.PERMTYPECODE as  PERM3_15_0_,  this.PERMNAME as  PERM4_15_0_,  this.PERMDESC as  PERM5_15_0_,  this.PORTNO as  PORT6_15_0_ from (select  t.perm_code as permCode, 
       t.module_code as moduleCode, 
       t.perm_name as permName, 
       t.perm_desc as permDesc, 
       t.port_no as portNo, 
       t.perm_type_code as permTypeCode 
  		from sys_perm t join sys_role_perm o 
    on t.perm_code = o.perm_code 
    where o.role_code = ? ) this  
(No.0)result size:1

 Execute No. 1 ********************
(No.1)result size:1
2008-10-06 17:26:26,484 [DEBUG](AbstractBatcher.java,324) - delete from SYS_ROLE_PERM where PERM_CODE=? and ROLE_CODE=?

 Execute No. 2 ********************
(No.2)result size:1

Time: 0.422

OK (1 test)
       </pre><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 从结果可以看出，第1次，执行了查询； <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 第2次没有执行查询，说明 query cache，二级cache都起了作用。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 但第3次查询，没有重新执行sql，仍然返回的是第二缓存的结果。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 因此可以判定， 第3次查出的是旧数据。<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 7. 分析及结论：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hibernate query cache 在关联表的数据删除时，没能通知查询缓存及时失效或更新， 以便获取最新数据。<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 8. 解决办法<br />&nbsp;&nbsp;&nbsp;&nbsp; 暂时还没找到Hibernate自身的解决办法， 为避免此问题，可以关闭查询缓存。 看大家有没有遇到过此问题，分享下你们的经验。<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; 如果hibernate真的没有解决这个问题，我能想到的一个思路就是，在 named query执行时，分析出查询的关联表，并在关联表进行 create，update，delete时及时通知该 named query的缓存失效。<br />&nbsp;&nbsp;&nbsp;&nbsp; 关联查询，特别是多表关联，且操作复杂时，要精细的进行缓存通知比较困难（例如：修改了 Admin 角色的授权，就对上例的查询没有影响，而修改了 STESTOR 角色的授权才需要通知cache更新，但这判断起来有一定难度），可以做一个笼统的逻辑，即 create，update，delete 关联表后，对 named query的cache都要通知它清除，以便重新查询获取最新数据。 <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query cache的利用率，即命中率取决于具体业务的增删改操作的频率，这个测试暂不考虑此因素 query cache的价值问题。
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249508" style="color:red;">已有 <strong>1</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 17:47:58 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249508</link>
        <guid>http://www.javaeye.com/topic/249508</guid>
      </item>
          <item>
        <title>SAP上海的情况</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://favor.javaeye.com">favor</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249480" style="color:red;">http://www.javaeye.com/topic/249480</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          各位大哥！知道SAP上海的都说一下！包括工作环境！工资等等...多多呀！
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249480" style="color:red;">已有 <strong>1</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 17:04:33 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249480</link>
        <guid>http://www.javaeye.com/topic/249480</guid>
      </item>
          <item>
        <title>IT公司风云榜 想跳槽的IT精英们可一定要进来看一下哦</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://sunnysun1985.javaeye.com">sunnysun1985</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249434" style="color:red;">http://www.javaeye.com/topic/249434</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          以下是近三个月以来深受好评的IT公司排名，想跳槽的IT精英们可一定要进来看一下哦<br />•	上海中信信息发展有限公司 <br />•	揖斐电电子科技（上海）有限公司<br />•	中国福网<br />•	SAP中国<br />•	上海直真视通科技有限公司<br />•	上海微创软件有限公司<br />•	上海今村通信技术有限公司<br />•	上海宝信软件股份有限公司 <br />•	navision <br />•	微软NAVISION A...
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249434" style="color:red;">已有 <strong>5</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 15:43:30 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249434</link>
        <guid>http://www.javaeye.com/topic/249434</guid>
      </item>
          <item>
        <title>2年开发，前途迷茫，欢迎大家交流～</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://candy-hr.javaeye.com">candy_hr</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249324" style="color:red;">http://www.javaeye.com/topic/249324</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          工作两年多了，觉得现在的生活不是自己想要的，工作忙碌，经常加班，做的事情没有什么挑战，一切按部就班。<br />带了一年项目，手下4人，有一些项目管理经验。发现自己还是比较喜欢技术，想搞些偏重技术或产品研发的事情。<br />有句话是这样说的“科学技术是第一生产力”，我始终坚信，但是现实中却不知何去何从，比较迷茫。<br /><br />项目经验：<br />做过四个项目，其中一个是工作流引擎的设计和开发，另外几个都是基于spring+hibernate或ibatis的企业应用项目，主要负责系统的设计、核心模块的开发。擅长java web开发，熟悉常用的开源框架、开发工具，了解J2EE相关规范。<br />目前在成都，税前4k，年底估计可以涨到5-5.5k，公司福利比较好。<br />只要安稳做下去也算可以，但我这个人不想安于现状。<br /><br />欢迎大家交流，赐教。<br />如果有职位可以推荐最好。
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249324" style="color:red;">已有 <strong>7</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 13:08:52 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249324</link>
        <guid>http://www.javaeye.com/topic/249324</guid>
      </item>
          <item>
        <title>开始找工作</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://donyee.javaeye.com">donyee</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249532" style="color:red;">http://www.javaeye.com/topic/249532</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">现在公司已经确定下来，年底北京分公司要搬到哈尔滨去，北京分公司本来是做开发，现在为了节省成本就撤呢。我不想去哈尔滨只好重新找工作（哈尔滨是个不错的城市，就是离家太远）。</span>
</p>
<p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">我比较偏好小型的公司，技术人员不要太多，一个项目组人员不要超过</span>
<span lang="EN-US">10</span>
<span style="font-family: 宋体;">个，薪水当然是越高越好，加班的话工作时间可以适当灵活一些。</span>
</p>
<p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">我的情况呢，我是<span lang="EN-US">07 </span>
年<span lang="EN-US">7</span>
月本科毕业后开始工作的，对于<span lang="EN-US">
Java </span>
比较熟悉，一直都是做<span lang="EN-US"> BS </span>
结构的管理系统，我现在的公司是做卡支付方面的，我负责前台的管理系统，也独立完成了几个系统的开发。对于<span lang="EN-US"> Java </span>
开发框架<span lang="EN-US"> Spring </span>
、<span lang="EN-US">
Hibernate </span>
、<span lang="EN-US"> Tapestry5 </span>
比较熟悉，能够开发应用，其他<span lang="EN-US"> web </span>
框架如<span lang="EN-US"> Struts&hellip; </span>
可以快速上手。其他<span lang="EN-US"> Html </span>
、<span lang="EN-US"> javascript </span>
、<span lang="EN-US">
css </span>
都有开发应用，我这管理系统都是我独立开发的，还负责一些简单的美工。</span>
</p>
<p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">对互联网有浓厚兴趣，看了许多高性能网络应用的文章，所以对这些架构有些了解。对一些常用的组件、程序我自己都有学习，如<span lang="EN-US"> Nginx </span>
服务器、<span lang="EN-US"> Memcached </span>
缓存组件，对<span lang="EN-US"> Linux </span>
常用命令熟悉，我们这的生产环境都是<span lang="EN-US"> Linux </span>
的。<span lang="EN-US"></span>
</span>
</p>
<p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">另外还了解<span lang="EN-US">Python,</span>
没有项目经验。 如果有<span lang="EN-US">python</span>
工作的话优先考虑。<span lang="EN-US"></span>
</span>
</p>
<p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">以上提到的框架、技术都是我自学来的，学习能力挺不错的，自我感觉良好。<span lang="EN-US"></span>
</span>
</p>
<p class="MsoNormal" style="margin-left: 15.75pt; text-indent: 21pt;"><span style="font-family: 宋体;">我在<span lang="EN-US">javaeye</span>
的<span lang="EN-US">blog-------http://donyee.javaeye.com/</span>
<span lang="EN-US"></span>
</span>
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;
<span style="font-size: 10.5pt; font-family: 宋体;">这些就算我的一些自我介绍吧，如果你对我的信息感兴趣，欢迎索取我的个人简历。我的电子邮箱<span lang="EN-US"> don.yee#163.com</span>
</span>
</p>
<p>&nbsp;</p>
<p>PS:最近都有时间，北京优先考虑</p>
<p>&nbsp;</p>
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249532" style="color:red;">已有 <strong>0</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 18:46:21 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249532</link>
        <guid>http://www.javaeye.com/topic/249532</guid>
      </item>
          <item>
        <title>关于联通Myunix系统，数据库设计的设想</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://linbzh.javaeye.com">linbzh</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249527" style="color:red;">http://www.javaeye.com/topic/249527</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p><span style="font-size: small;">联通myuni系统 <span style="color: #008000;"><a href="http://www.myuni.com.cn/">www.myuni.com.cn</a>&nbsp;</span><span style="color: #000000;">其登陆功能，看似简单，但是联通的用户全国有几亿，如果要在几秒的时间内登陆成功，数据库设计部分如果安装常规的设计是行不通的（而这个系统确实可以在几秒之内登陆成功）。下面是我个人的一点想法：</span></span></p>
<p><span style="font-size: small;">&nbsp;</span></p>
<p><span style="font-size: small;">基本思想就是裁表。把用户表（主键为号码）根据号码的特点进行裁分，例如有号码100到300，那么可以把这个范围的数字裁成4部分，100-150，对应表名为100；151-200，对应表名为151；201-250，对应表名为201；251-300，对应表名为251，而用到这些表的主键作为外键的表，外键的设置全部撤销，改为普通键，要连接这些表就根据值的范围确定表名。</span></p>
<p><span style="font-size: small;">&nbsp;</span></p>
<p><span style="font-size: small;">这是，本人的一些设想，不知道开发方是怎么做的，如果其他高手有什么更好的想法，一起讨论一下！</span></p>
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249527" style="color:red;">已有 <strong>0</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 18:37:39 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249527</link>
        <guid>http://www.javaeye.com/topic/249527</guid>
      </item>
          <item>
        <title>一道Java I/O的笔试题</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://hyxw5890.javaeye.com">hyxw5890</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249467" style="color:red;">http://www.javaeye.com/topic/249467</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          假设D:/dir目录下放着100个文件,文件名为:file001.txt,file002,file003.txt......file100.txt。请写一高效程序，将这100个文件的内容按文件名编号顺序合并成一个文件file.txt。<br /><br />这题的一般思路是：<br />1、实现filenameFilter接口对文件按编号排序。<br />2、利用PrintWriter创建file.txt准备写入<br />3、用bufferedReader依次打开每个文件，然后每读一行，就写入一行。这里不把每个文件内容<br />存在内存里然后一并写入的目的是防止文件内容过大。<br /><br />有什么其他更高效的方法吗，比如利用NIO？
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249467" style="color:red;">已有 <strong>3</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 16:32:13 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249467</link>
        <guid>http://www.javaeye.com/topic/249467</guid>
      </item>
          <item>
        <title>想对新人说的一些话.</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://zhaobohao.javaeye.com">zhaobohao</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249178" style="color:red;">http://www.javaeye.com/topic/249178</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          上一个工作日,公司要招两个java初级程序员.基本工资定在3K-,在一天内,我面试了12个人.看了100-份简历.<br />现将自己的一些想法记录如下,给有需要的人看一下.<br /><br />1.简历不必写太多精通的东西,大公司会有自己的开发环境,小公司也会有自己的技术方向.写的太多,在面试的时候,随便问你两个,都答不上来,美其名曰:时间太长了,有点生了.<br /><br />2.给你的面试题还是要做的,其实大家关心的并不是你的答案是对是错,而是你的思维方式,还有你的语言表达能力.我从baidu上找了一份试题,过来面试的人一看就说,都是些网上的东西.我让大家口述...结果有的人能说明白,有些人声音小,有些人口齿不清,有些人,想了半天说都是很简单的东西,我不想做.<br /><br />3.学历真的很重要.............................................还有鸟语.................................<br /><br />4.要谦虚.既然写名了是招初级程序员,就没有指望你上通天文,下晓地理.不会的可以学.但自己什么都会,那就给我上培训课吧.<br /><br />5.常去javaeye上看看....多看看我发的回复...........
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249178" style="color:red;">已有 <strong>5</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 00:28:22 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249178</link>
        <guid>http://www.javaeye.com/topic/249178</guid>
      </item>
          <item>
        <title>JavaScript中的继承学习笔记(1)：Crockford uber方法中的陷阱</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://lifesinger.javaeye.com">lifesinger</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/248933" style="color:red;">http://www.javaeye.com/topic/248933</a>&nbsp;
          发表时间: 2008年10月04日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          原文同步发表在<a href="http://lifesinger.org/blog/?p=192" target="_blank">岁月如歌</a>，欢迎讨论交流。<br /><br />先来看 Douglas Crockford 的经典文章：<a href="http://javascript.crockford.com/inheritance.html" target="_blank">Classical Inheritance in JavaScript</a>. 此文的关键技巧是给Function.prototype增加inherits方法，代码如下（注释是我的理解）：<br /><pre name="code" class="javascript">
Function.prototype.method = function (name, func) {
	this.prototype[name] = func;
	return this;
};

Function.method('inherits', function (parent) {
	var d = {}, // 递归调用时的计数器
		// 下面这行已经完成了最简单的原型继承：将子类的prototype设为父类的实例
		p = (this.prototype = new parent());
	
	// 下面给子类增加uber方法（类似Java中的super方法），以调用上层继承链中的方法
	this.method('uber', function uber(name) {
		if (!(name in d)) {
			d[name] = 0;
		}
		var f, r, t = d[name], v = parent.prototype;
		if (t) {
			while (t) {
				// 往上追溯一级
				v = v.constructor.prototype;
				t -= 1;
			}
			f = v[name];
		} else {
			f = p[name];
			if (f == this[name]) {
				f = v[name];
			}
		}
		// 因为f函数中，可能存在uber调用上层的f
		// 不设置d[name]的话，将导致获取的f始终为最近父类的f（陷入死循环）
		d[name] += 1;
		
		// slice.apply的作用是将第2个及其之后的参数转换为数组
		// 第一个参数就是f的名字，无需传递
		// 这样，通过uber调用上层方法时可以传递参数：
		// sb.uber(methodName, arg1, arg2, ...);
		r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));
		
		// 还原计数器
		d[name] -= 1;
		
		return r;
	});
	// 返回this, 方便chain操作
	return this;
});
</pre><br />上面d[name]不好理解，我们来创建一些测试代码：<br /><pre name="code" class="javascript">
function println(msg) {
	document.write(msg + '&lt;br />');
}

// 例1
function A() { }
A.prototype.getName = function () { return 'A'; }; // @1

function B() { }
B.inherits(A);
B.prototype.getName = function () { return this.uber('getName') + ',B'; }; // @2

function C() { }
C.inherits(B);
C.prototype.getName = function () { return this.uber('getName') + ',C'; }; // @3

var c = new C();
println(c.getName()); // => A,B,C
println(c.uber('getName')); // => A,B
</pre><br />c.getName()调用的是@3, @3中的uber调用了@2. 在@2中，又有this.uber('getName'), 这时下面这段代码发挥作用：<br /><pre name="code" class="javascript">
while (t) {
	// 往上追溯一级
	v = v.constructor.prototype;
	t -= 1;
}
f = v[name];
</pre><br />可以看出，d[name]表示的是递归调用时的层级。如果不设此值，@2中的this.uber将指向@2本身，这将导致死循环。Crockford借助d[name]实现了uber对同名方法的递归调用。<br /><br />uber只是一个小甜点。类继承中最核心最关键的是下面这一句：<br /><pre name="code" class="javascript">
p = (this.prototype = new parent());
</pre><br /><strong>将子类的原型设为父类的一个实例，这样子类就拥有了父类的成员，从而实现了一种最简单的类继承机制。</strong>注意JavaScript中，获取obj.propName时，会自动沿着prototype链往上寻找。这就让问题变得有意思起来了：<br /><pre name="code" class="javascript">
// 例2
function D1() {}
D1.prototype.getName = function() { return 'D1' }; // @4

function D2() {}
D2.inherits(D1);
D2.prototype.getName = function () { return this.uber('getName') + ',D2'; }; // @5

function D3() {}
D3.inherits(D2);

function D4() {}
D4.inherits(D3);

function D5() {}
D5.inherits(D4);
D5.prototype.getName = function () { return this.uber('getName') + ',D5'; }; // @6

function D6() {}
D6.inherits(D5);

var d6 = new D6();
println(d6.getName()); // => ?
println(d6.uber('getName')); // => ?
</pre><br />猜猜最后两行输出什么？按照uber方法设计的原意，上面两行都应该输出D1,D2,D5, 然而实际结果是：<br /><pre name="code" class="javascript">
println(d6.getName()); // => D1,D5,D5
println(d6.uber('getName')); // => D1,D5
</pre><br />这是因为Crockford的inherits方法中，考虑的是一种理想情况（如例1），对于例2这种有“断层”的多层继承，d[name]的设计就不妥了。我们来分析下调用链：<br /><br />d6.getName()首先在d6对象中寻找是否有getName方法，发现没有，于是到D6.prototype(一个d5对象)中继续寻找，结果d5中也没有，于是到D5.protoype中寻找，这次找到了getName方法。找到后，立刻执行，注意this指向的是d6. this.uber('getName')此时表示的是d6.uber('getName'). 获取f的代码可以简化为：<br /><pre name="code" class="javascript">
// 对于d6来说, parent == D5
var f, v = parent.prototype;
f = p[name];
// 对于d6来说，p[name] == this[name]
if (f == this[name]) {
    // 因此f = D5.prototype[name]
    f = v[name];
}

// 计数器加1
d[name] += 1;

// 等价为 D5.prototype.getName.apply(d6);
f.apply(this);
</pre><br />至此，一级调用d6.getName()跳转进入二级递归调用D5.prototype.getName.apply(d6). 二级调用的代码可以简化为：<br /><pre name="code" class="javascript">
var f, t = 1, v = D5.prototype;
while (t) {
	// 这里有个陷阱，v.constructor == D1
	// 因为 this.prototype = new parent(), 形成了下面的指针链：
	// D5.prototype = d4
	// D4.prototype = d3
	// D3.prototype = d2
	// D2.prototype = d1
	// 因此v.constructor == d1.constructor
	// 而d1.constructor == D1.prototype.constructor
	// D1.prototype.constructor指向D1本身，因此最后v.constructor = D1
	v = v.constructor.prototype;
	t -= 1;
}
// 这时f = D1.prototype.getName
f = v[name];

d[name] += 1;
// 等价为 D1.prototype.getName.apply(d6)
f.apply(this);
</pre><br />上面的代码产生最后一层调用：<br /><pre name="code" class="javascript">
return 'D1';
</pre><br />因此d6.getName()的输出是D1,D5,D5.<br />同理分析，可以得到d6.uber('getName')的输出是D1,D5.<br /><br />上面分析了“断层”时uber方法中的错误。注意上面提到的v.constructor.prototype产生的陷阱，这个陷阱在“非断层”的理想继承链中也会产生错误：<br /><pre name="code" class="javascript">
// 例3
function F1() { }
F1.prototype.getName = function() { return 'F1'; };

function F2() { }
F2.inherits(F1);
F2.prototype.getName = function() { return this.uber('getName') + ',F2'; };

function F3() { }
F3.inherits(F2);
F3.prototype.getName = function() { return this.uber('getName') + ',F3'; };

function F4() { }
F4.inherits(F3);
F4.prototype.getName = function() { return this.uber('getName') + ',F4'; };

var f3 = new F3();
println(f3.getName()); // => F1,F2,F3

var f4 = new F4();
println(f4.getName()); // => F1,F3,F4
</pre><br />很完美的一个类继承链，但f4.getName()没有产生预料中的输出，这就是v.constructor.prototype这个陷阱导致的。<br /><br /><strong>小结</strong><br /><ul><li>在JavaScript中，模拟传统OO模型来实现类继承不是一个很好的选择（上面想实现一个uber方法都困难重重）。</li><li>在JavaScript中，考虑多重继承时，要非常小心。尽可能避免多重继承，保持简单性。</li><li>理解JavaScript中的普通对象，Function对象，Function对象的prototype和constructor, 以及获取属性时的原型追溯路径非常重要。（比如上面提到的constructor陷阱）</li><li>Crockford是JavaScript界的大仙级人物，但其代码中依旧有陷阱和错误。刚开始我总怀疑是不是自己理解错了，费了牛劲剖析了一把，才敢肯定是Crockford考虑不周，代码中的错误是的的确确存在的。学习时保持怀疑的态度非常重要。</li></ul><br /><br /><strong>后续</strong><br /><br />上面的分析花了一个晚上的时间，今天google了一把，发现对Crockford的<a href="http://blog.csdn.net/chensheng913/archive/2006/12/28/1465741.aspx" target="_blank">uber方法中的错误</a>能搜到些零星文章，还有人给出了<a href="http://hax.pie4.us/2006/12/bug-of-douglas-crockfords-uber.html" target="_blank">修正方案</a>（忍不住八卦一把：从链接上看，是CSDN上的一位兄弟第一次指出了Crockford uber方法中的这个bug，然后John Hax（估计也是个华人）给出了修正方案。更有趣的是，Crockford不知从那里得知了这个bug, 如今<a href="http://javascript.crockford.com/inheritance.html" target="_blank">Classical Inheritance in JavaScript</a>这篇文章中已经是修正后的版本^o^）。<br /><br />这里发现的uber方法中的<strong>constructor陷阱</strong>，尚无人提及。导致constructor陷阱的原因是：<br /><pre name="code" class="javascript">
p = (this.prototype = new parent());
</pre><br />上面这句导致while语句中v.constructor始终指向继承链最顶层的constructor. 分析出了原因，patch就简单了：<br /><pre name="code" class="javascript">
// patched by lifesinger@gmail.com 2008/10/4
Function.method('inherits', function (parent) {
    var d = { }, 
        p = (this.prototype = new parent());
        // 还原constructor
        p.constructor = this;
        // 添加superclass属性
        p.superclass = parent;
                
    this.method('uber', function uber(name) {
        if (!(name in d)) {
            d[name] = 0;
        }
        var f, r, t = d[name], v = parent.prototype;
        if (t) {
            while (t) {
                // 利用superclass来上溯，避免contructor陷阱
                v = v.superclass.prototype;
                // 跳过“断层”的继承点
                if(v.hasOwnProperty(name)) {
                    t -= 1;
                }
            }
            f = v[name];
        } else {
            f = p[name];
            if (f == this[name]) {
                f = v[name];
            }
        }
        d[name] += 1;        
        if(f == this[name]) { // this[name]在父类中的情景
            r = this.uber.apply(this, Array.prototype.slice.apply(arguments));
        } else {
            r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));
        }
        d[name] -= 1;
        return r;
    });
    return this;
});
</pre><br />测试页面：<a href="/blog/wp-content/uploads/2008/10/crockford_classic_inheritance_test.html" target="_blank">crockford_classic_inheritance_test.html</a><br /><br />最后以Douglas Crockford的总结结尾：<br /><div class="quote_title">引用</div><div class="quote_div"><br />我编写JavaScript已经8个年头了，从来没有一次觉得需要使用uber方法。在类模式中，super的概念相当重要；但是在原型和函数式模式中，super的概念看起来是不必要的。现在回顾起来，我早期在JavaScript中支持类模型的尝试是一个错误。<br /></div>
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/248933" style="color:red;">已有 <strong>9</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sat, 04 Oct 2008 21:21:17 +0800</pubDate>
        <link>http://www.javaeye.com/topic/248933</link>
        <guid>http://www.javaeye.com/topic/248933</guid>
      </item>
          <item>
        <title>django单机能支撑2000wpv？</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://molinshow.javaeye.com">molinshow</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249234" style="color:red;">http://www.javaeye.com/topic/249234</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          今天在网上搜了一下看看有什么nginx+fastcgi+django的文章。结果搜到了这篇<br /><a href="http://taoyh163.blog.163.com/blog/static/19580356200802433559850/" target="_blank">http://taoyh163.blog.163.com/blog/static/19580356200802433559850/</a><br />文中提到他的应用流量达到2000w/day。不禁眼前一亮。。。<div class="quote_title">引用</div><div class="quote_div">硬件是一台 DELL的PC Server(双核Xeon1个，2G内存)，操作系统是redhat as4，其他的还有nginx 0.5.33，python 2.5，mysql 5.0.41，django是10月份左右从svn trunk取下来的</div>这是文中提到的配置。所有服务仅在一台服务器上。<img src="/images/smiles/icon_mad.gif"/>是吹牛人。。还是大牛人
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249234" style="color:red;">已有 <strong>1</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 10:24:23 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249234</link>
        <guid>http://www.javaeye.com/topic/249234</guid>
      </item>
          <item>
        <title>图论—深度优先和广度优先算法源码</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cxlh.javaeye.com">kongshanxuelin</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249333" style="color:red;">http://www.javaeye.com/topic/249333</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>最近由于项目需要，需要实现深度优先和广度优先算法，图论中的基础内容，源代码共享一下，希望对大家有用：</p>
<pre name="code" class="java">public class Graph {
	private final int MAX_VERT=500;
	private Node nodelist[];
	private int adjMat[][];
	private int nverts;
	private Stack theStack;
	private Queue theQuene;
	
	public Graph(){
		//顶点数组
		nodelist=new Node[MAX_VERT];
		//邻接矩阵
		adjMat = new int[MAX_VERT][MAX_VERT];
		nverts=0;
		for(int i=0;i&lt;MAX_VERT;i++){
			for(int j=0;j&lt;MAX_VERT;j++){
				adjMat[i][j]=0;
			}
		}
		theStack=new Stack();
		theQuene=new LinkedList();
		sortedArray = new BusSiteBean[MAX_VERT];
	}
	
	/**
	 * 增加一定点
	 * @param node
	 */
	public void addNode(Node node){
		nodelist[nverts++]=node;
	}
	
	/**
	 * 增加一边
	 * @param start
	 * @param end
	 */
	public void addEdge(int start,int end){
		adjMat[start][end]=1;
		//有向图
		//adjMat[end][start]=1;
	}
	
	public int getAdjUnVisited(int v){
		for(int j=0;j&lt;nverts;j++){
			if(adjMat[v][j]==1&amp;&amp;nodelist[j].isWasVisited()==false){
				return j;
			}
		}
		return -1;
	}
	
	/**
	 * 深度优先搜索算法
	 */
	public void dfs(){
		nodelist[0].setWasVisited(true);
		displayNode(0);
		theStack.push(0);
		while(!theStack.isEmpty()){
			int v=((Integer)theStack.peek()).intValue();
			v=getAdjUnVisited(v);
			
			if(v==-1){
				theStack.pop();
			}else{
				nodelist[v].setWasVisited(true);
				displayNode(v);
				theStack.push(v);
			}
		}
		for(int j=0;j&lt;nverts;j++){
			nodelist[j].setWasVisited(false);
		}
	}
	
	/**
	 * 广度优先搜索算法
	 */
	public void bfs(){
		this.nodelist[0].setWasVisited(true);
		this.displayNode(0);
		this.theQuene.add(0);
		int v2;
		while(!this.theQuene.isEmpty()){
			int v1=((Integer)this.theQuene.remove()).intValue();
			while((v2=this.getAdjUnVisited(v1))!=-1){
				this.nodelist[v2].setWasVisited(true);
				displayNode(v2);
				this.theQuene.add(v2);
			}
		}
		for(int j=0;j&lt;nverts;j++){
			nodelist[j].setWasVisited(false);
		}		
	}
	
	private int noSuccessors(){
		boolean isEdge;
		for(int row=0;row&lt;this.nverts;row++){
			isEdge=false;
			for(int col=0;col&lt;this.nverts;col++){
				if(adjMat[row][col]&gt;0){
					isEdge=true;
					break;
				}
			}
			if(!isEdge)
				return row;
		}
		return -1;
	}
	
	/**
	 * 有向图拓扑
	 */
	public void poto(){
		int orig_nverts=this.nverts;
		while(this.nverts&gt;0){
			int currentNode=noSuccessors();
			if(currentNode==-1){
				System.out.println(&quot;Graph 有环&quot;);
				return;
			}
			sortedArray[this.nverts-1]=nodelist[currentNode].getBs();
			deleteNode(currentNode);
		}
		for(int j=0;j&lt;orig_nverts;j++){
			System.out.print(sortedArray[j]);
		}
	}
	
	private void deleteNode(int delVert){
		if(delVert!=this.nverts-1){
			for(int j=delVert;j&lt;this.nverts-1;j++)
				this.nodelist[j]=this.nodelist[j+1];
			for(int row=delVert;row&lt;this.nverts-1;row++)
				moveRowUp(row,this.nverts);
			for(int col=delVert;col&lt;this.nverts-1;col++)
				moveRowLeft(col,this.nverts-1);
		}
		this.nverts--;		
	}
	private void moveRowUp(int row,int length){
		for(int col=0;col&lt;length;col++)
			adjMat[row][col]=adjMat[row+1][col];
	}
	
	private void moveRowLeft(int col,int length){
		for(int row=0;row&lt;length;row++)
			adjMat[row][col]=adjMat[row][col+1];	
	}

	public void displayNode(int v){
		System.out.println(nodelist[v].getBs().toString());
	}
	
	public static void main(String[] args) {
		Graph g=new Graph();
		g.addNode(new Node(new BusSiteBean(&quot;A&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;B&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;C&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;D&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;E&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;F&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;G&quot;)));
		g.addNode(new Node(new BusSiteBean(&quot;H&quot;)));
		
		g.addEdge(0, 3);
		g.addEdge(0, 4);
		g.addEdge(1, 4);
		g.addEdge(2, 5);
		g.addEdge(3, 6);
		g.addEdge(4, 6);
		g.addEdge(5, 7);
		g.addEdge(6, 7);
		
		g.poto();
	}
}</pre>
&nbsp;
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249333" style="color:red;">已有 <strong>2</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 13:21:26 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249333</link>
        <guid>http://www.javaeye.com/topic/249333</guid>
      </item>
          <item>
        <title>Java 存取MySQL大文件问题</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://it-lian.javaeye.com">lian860911</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249036" style="color:red;">http://www.javaeye.com/topic/249036</a>&nbsp;
          发表时间: 2008年10月05日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          项目中遇到一个问题：关于文件上传下载<br />&nbsp;&nbsp; 需求要求必须文件必须必须写入数据库(<span style="color: red">MySQL</span>)中，并且要支持大文件（字段类型是<span style="color: red">longblob</span>）；<br />&nbsp;&nbsp; <span style="color: red">现在的问题是：</span><br />&nbsp;&nbsp; <span style="color: red">1.上传时候我们把大文件分块在数据库中进行拼接：</span><br /><pre name="code" class="java">
UPDATE t_blob SET LB_A = concat(LB_A, ?) WHERE [condition] //只修改一条记录
</pre><br />.........<br /><pre name="code" class="java">
ps.setBytes(1, buffer);//从流中读取指定长度的字节数组
ps.execute(); 
</pre><br />&nbsp;&nbsp; 这样做到是能实现大文件上传，但是如果分块太小，速度非常慢，巨慢。。。<br />&nbsp;&nbsp; <span style="color: red">2.文件下载的时候始终报Out of memory错误</span><br /><pre name="code" class="java">   select * from t_blob where [condition] //只取了一条记录
   ResultSet rs=ps.executeQuery();//程序在这里出错</pre><br />&nbsp;&nbsp; Mysql的文档上说Blob类型在执行查询时要把全部内容一次取出，这样内存就不够了<br />&nbsp;&nbsp; <span style="font-size: large">请问有没有什么解决办法呢？</span>
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249036" style="color:red;">已有 <strong>2</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sun, 05 Oct 2008 11:14:47 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249036</link>
        <guid>http://www.javaeye.com/topic/249036</guid>
      </item>
          <item>
        <title>找个工作，经验1年，地点北京！！</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://green-coffee-126-com.javaeye.com">green_coffee@126.com</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249349" style="color:red;">http://www.javaeye.com/topic/249349</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          求职意向：java工程师 <br />期望月薪：3000元<br />个 人 简 历<br />个人信息:<br /> <br />姓&nbsp;&nbsp;&nbsp; 名：王波&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 性&nbsp;&nbsp; 别：男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />年&nbsp;&nbsp;&nbsp; 龄：23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 工作经验：1年<br />电&nbsp;&nbsp;&nbsp; 话：15001122713&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 信&nbsp;&nbsp;&nbsp; 箱：green_coffee@126.com<br />---------------------------------------------------------------------------------------------<br />专业技能:<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 熟练掌握基于J2EE架构的Java Web编程。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 熟悉MVC模式，熟练应用Hibernate、Struts等主流框架进行项目开发，熟悉Sping。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 熟练使用css、javascript、ajax、dwr、jstl等。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 熟练使用oracle,sqlserver等数据库进行项目设计及开发。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 熟练使用Deamveaver、Eclipse、PLSQL、IREPORT等常用项目开发软件。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 熟练使用svn、cvs等版本控制。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 了解C、ASP、ASP.NET等周边编程语言。<br />Ø&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 了解LINUX操作系统。<br /> <br />经验阅历:<br /> <br />1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 曾于软件学校学习编程1年，在此段时间掌握了JAVA编程并积累了项目经验，由本人负责设计开发的模拟项目均名列前茅。<br />2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 曾于青岛海易软件参与实习，锻炼了开发设计项目的能力。<br />3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 于青岛红霞电子信息工程有限公司担任软件工程师至今，负责参与了多个项目的开发设计，并参与设计开发了青岛市南幼儿园信息采集系统、青岛市小学新生报名录取系统等项目，均获得青岛媒介关注。<br /> <br />项目经验:<br /> <br />1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 齐鲁商情商务网站<br />软件环境：tomcat6.0和jdk5.0<br />开发工具：eclipse3.3+myeclipse6.0+oracle9i<br />开发人数：3人<br />项目描述：此项目是一个完整的电子商务平台，实现了用户购物，商品发布等一系列的商务服务。具体功能如下：1.普通用户——可在普通用户中心对个人信息、个人订单、商品评论、站内消息等进行管理。2.商家用户——可在商家用户中心对商家信息、商品品牌、商家商品、商家商情、用户订单、用户评论、商品管理、订单处理、商情专家、商家仓库、货物购入、站内消息（包含手机短信）等进行管理。3.后台管理员——可在网站后台管理中心对管理员、商品类别、公告类别、新闻类别、专家类别、操作日志、前台用户、网站公告、用户留言等进行管理。<br />责任描述：系统主要设计开发人员，主要完成里面策略定制模块的设计，以及从前台到后台的实现。<br /><br />2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 青岛市南幼儿园信息采集系统<br />软件环境：tomcat6.0和jdk5.0<br />开发工具：eclipse3.3+myeclipse6.0+sqlserver2000<br />开发人数：4人<br />项目描述：此系统主要针对幼儿园信息的管理，真正实现远程办公、异地办公，满足各幼儿园现在和将来对信息资源采集、存储、处理、组织、管理和利用的需求，实现信息资源的高度集成与共享，实现信息资源的集中管理和统一调度。此系统主要分为三部分，信息采集、代收费统计和新生报名。信息采集块主要包含幼儿园基本情况管理(经费，办学条件等)、学生管理(学生来源，家庭情况等)、教师管理(信息，考核等)，总管理员可进行多个学校管理，进行统一调度，并可自主分配子管理员，各学校管理员可自主管理本校信息。代收费统计块依赖于另一收费系统，主要用于对复杂数据进行简化统计，跟踪幼儿园收费情况。新生报名块用于新学生的招收，简化大数据量的学生分配工作，学校学生入学可自动按地址分配学校。<br />责任描述：参与项目设计，并负责核心代码的编写。<br /> <br />自我评价:<br /> <br />本人热爱本行工作，善于专研，敢于探索，对工作认真负责充满热情，对工作细节力求完美。<br />本人为人诚实守信，有良好的人际关系，善于团队合作。<br />我是一个自信心很强的人，我相信我能很快融入到公司中并迅速成为公司骨干，为公司发展出一份力！
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249349" style="color:red;">已有 <strong>5</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 14:03:21 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249349</link>
        <guid>http://www.javaeye.com/topic/249349</guid>
      </item>
          <item>
        <title>南京 高级JAVA程序员 外包</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://simonjiafa.javaeye.com">simonjiafa</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249498" style="color:red;">http://www.javaeye.com/topic/249498</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          本公司在南京，有一些外包项目寻求高级JAVA程序员（只限南京，只限个人，方便交流，团队勿扰）；具体需求为：熟悉JAVA的MVC开发，熟悉Spring框架，了解Hibernate等。有意者请发邮件到：rome360@rome360.net;或者QQ联系：875231132
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249498" style="color:red;">已有 <strong>0</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 17:30:29 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249498</link>
        <guid>http://www.javaeye.com/topic/249498</guid>
      </item>
          <item>
        <title>关于Spring 2.5里面的基于注解的配置的一些疑惑</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://caipanjin.javaeye.com">caipanjin</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249496" style="color:red;">http://www.javaeye.com/topic/249496</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          开门见山吧<br /><br />第一个问题：Spring和iBatis整合的时候，我让一个Dao继承SqlMapClientDaoSupport，我怎样用注解注入sqlMapClient？我不想action和service都用注解注入，但是我的dao得用xml注入。（当然有人会说，可以抽象出一个父类dao，由它在xml里面注入sqlMapClient，然后子类dao就可以用注解注入了，这倒可以的。那有没有直接点的方法呢？）<br /><br />第二个问题：单元测试的时候，@Resource注解注入有效，比如在service里面注入dao。到web程序上去跑，就null了，action里面注入的service是null，service里面注入的dao也是null，改成@Autowired就OK了，但是这种现象如何解释呢？而且我不太喜欢用@Autowired，似乎感觉它的效率要差点。<br /><br />大家知道的给我讲讲吧。
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249496" style="color:red;">已有 <strong>0</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 17:29:48 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249496</link>
        <guid>http://www.javaeye.com/topic/249496</guid>
      </item>
          <item>
        <title>一行代码搞定ActiveRecord的二级缓存</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://quake.javaeye.com">Quake Wang</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249284" style="color:red;">http://www.javaeye.com/topic/249284</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <span style="font-size: large">背景介绍：</span><br /><br />JavaEye在今年1月份发布新版本以来，一直在使用cache_fu插件为整个网站提供缓存功能，在使用cache_fu时有遇到一些api调用不方便的问题：<br />1. 它没有对find(id)方法进行重写：<br /><pre name="code" class="ruby">
class User &lt; ActiveRecord::Base
  acts_as_cached
end

#find没有使用cache机制
User.find(params[:id])
#必需使用get_cache方法，才能让cache生效
User.get_cache(params[:id])
</pre><br /><br />2. 它没有提供belongs_to, has_one等关系上的缓存机制<br /><pre name="code" class="ruby">
class Topic &lt; ActiveRecord::Base
  belongs_to :user
end

#不会使用cache机制
topic.user
</pre><br /><br />3. 它没有针对ActiveRecord的update/destroy做callback，进行expire cache的工作<br /><br />当然这些问题都可以通过自己写一点代码来改善，比如问题2：<br /><a href="http://www.javaeye.com/topic/239580" target="_blank">cache_fu的关联补丁(belongs_to, has_one)</a><br /><br /><br /><span style="font-size: large">Rails.cache来了：</span><br /><br />在Rails2.1以后，Rails提供了一个内置的缓存机制（Rails.cache），看了<a href="http://www.thewebfellas.com/blog/2008/6/9/rails-2-1-now-with-better-integrated-caching" target="_blank">相关的文章</a>介绍以后，我觉得完全可以利用它来取代cache_fu，自制一个简单的ActiveRecord二级缓存。<br /><br />首先整理一下我们的需求，和Hibernate提供的二级缓存机制很类似：<br />1. 对于被标记为使用cache的Model，我们调用find(id)方法，将会先从cache中查找。<br />2. 对于belongs_to/has_one等关系的一方，如果该model被标记为使用cache，调用关系方法的时候也将会先从cache中查找。<br />3. update/destroy被缓存的模型能够自动清除缓存。<br /><br />通过阅读ActiveRecord的源码，发现其实我们只需要在Base.find_one方法上做一些小动作就可以了：<br /><pre name="code" class="ruby">
def find_one_with_cache(id, options)
  Rails.cache.fetch(cache_key(id)) {find_one_without_cache(id, options)}
end

alias_method_chain :find_one, :cache
</pre><br />一行代码就搞定了1和2的需求，需求3也很简单，写2个after_update/after_destroy的事件就可以了，也是一行代码搞定<br />最终的代码见附件，我承认做了一回标题党，其实搞定这个自制插件最终用了大概50行左右的代码，但是每个核心方法还是只有1~2行&nbsp;<img src="/images/smiles/icon_smile.gif"/>，我想这得益于Ruby的语言特性和Rails的设计<br /><br /><br /><span style="font-size: large">如何使用：</span><br /><br />只需要将文件解压到plugins目录下面，然后在environment.rb或者production.rb配置具体的cache机制即可：<br /><pre name="code" class="ruby">
config.cache_store = :mem_cache_store
</pre><br /><br />然后在你需要做缓存的对象上加上一句acts_as_cached（这里为了从cache_fu方便迁移，我使用了同名）。<br /><pre name="code" class="ruby">
class User &lt; ActiveRecord::Base
  acts_as_cached
end
</pre><br />然后观察log，就会出现类似这样的输出，说明缓存起作用了：<br />Cache miss: User/1 ({})<br />Cache hit: User/1 ({})<br />Cache hit: User/1 ({})<br /><br /><br /><span style="font-size: large">小技巧： </span><br /><br />1. 定义缓存失效时间： acts_as_cached :expires_in => 6.hours<br />2. 在单元测试代码中禁用缓存，你可以在environment/test.rb里面设置一个无法访问的memcache地址，比如：<br />config.cache_store = :mem_cache_store, "disable.test.cache.localhost"<br />3. 类似hibernate的query cache：<br /><pre name="code" class="ruby">
class Forum &lt; ActiveRecord::Base
  acts_as_cached
  def self.all_for_option
    get_cache("all_for_options") {find(:all, :order => 'category, position')}
  end  
end
</pre><br />不过这个简单插件没有提供hibernate那样完善的对query cache自动清理的功能，你可以试试看添加这个特性<br />4. memcached的undefined class/module错误，从cache_fu抄袭了一个autoload_missing_constants方法来解决这个问题：<br /><a href="http://www.philsergi.com/2007/06/rails-memcached-undefinded-classmodule.html" target="_blank">http://www.philsergi.com/2007/06/rails-memcached-undefinded-classmodule.html</a><br /><br /><br />最后show一下JavaEye的<a href="http://pecl.php.net/package/memcache" target="_blank">memcache stats</a><br /><img src="http://www.javaeye.com/upload/attachment/41180/7fb9f4c0-76b3-3217-8901-30f2a4df4bf8.png" />
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249284" style="color:red;">已有 <strong>10</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 11:59:07 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249284</link>
        <guid>http://www.javaeye.com/topic/249284</guid>
      </item>
          <item>
        <title>应用程序的瓶颈？</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://gembler.javaeye.com">gembler</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249147" style="color:red;">http://www.javaeye.com/topic/249147</a>&nbsp;
          发表时间: 2008年10月05日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>最近。。。手头上项目成形了，心里暗喜（可以稍微清闲一点了）。<br />谁知道跑了几天，程序访问不了（喜不出来了）。<br />从error log中得知是PermGen space（开始狂抓了），而且该进程占用cup的百分比是在100%~105%之间浮动。<br /><br /><br />应用程序结构：struts+spring+hibernate。<br /><br />数据库：oracle<br /><br />应用服务器：jboss<br /><br />操作系统：redhat<br /><br />负载均衡：F5<br /><br />JDK：1.5<br /><br /><br />知道是报PermGen space，第一反应当然是修改JAVA_OPTS，可是跑几天问题依然重出（再抓）。<br />这时候，开始断定是代码问题了，然后用jconsole去监控监控，看不到我想看的东西（汗）。<br /><br /><br />目前我想监控的内容是：某个类的实例数量、所占的内存，某个实例所占的内存。</p>
<p>&nbsp;</p>
<p>（过两天跑去尝试一下jprofile）<br /><br />如果大家有好的监控工具，就介绍介绍，<br /><br />有其他的测试方案、压测工具也介绍介绍介绍，<br /><br />有知道导致出现PermGen space的其他原因的也介绍介绍介绍介绍</p>
<p>&nbsp;</p>
<p>或者其他高见 --&gt; 尽管提出提出。</p>
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249147" style="color:red;">已有 <strong>5</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sun, 05 Oct 2008 22:04:20 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249147</link>
        <guid>http://www.javaeye.com/topic/249147</guid>
      </item>
          <item>
        <title>Struts2+spring2.5.5+Hibernate3.1.1+外网访问内网的苹果茶+Mysq</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://ilysony.javaeye.com">ilysony</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249285" style="color:red;">http://www.javaeye.com/topic/249285</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          做了一个小网站,来学习SSH <br /><br />Struts2+spring2.5.5+Hibernate3.1.1+外网访问内网的苹果茶+Mysql <br /><br />苦于不能在外网访问,因我是内网,又没权限搞端口映射' <br /><br />于是GOOGLE BAIDU了一大堆,最后发现都用不了, <br /><br />无意中发现了苹果茶,真是太好用了 <br /><br />安装后,tomcat一开就可以访问了,爽 <br /><br />分享一下,分享给那些和我一样,在内网搭建服务器的人 <br /><br />http://ilysony.meibu.org:12649/znt/&nbsp; 我用SSH做的小站,大家多提批语意见 <br /><br /><br />下面是苹果茶的使用方法 <br /><br />--------------- <br /><br />不需要端口映射实现从外网访问内网服务器 2008-10-06 11:28:14 <br /><br /><br />1、 <br />去 www.meibu.org 注册域名（注册域名是免费的）； <br />2、 <br />去 http://www.meibu.org/khd.html 下载“苹果茶”内网服务客户端软件； <br />3、 <br />先不要运行软件登陆，我们这个时候要先把SQL的端口设置一下。先去 www.meibu.org 用刚才申请的域名和密码登陆，进到了端口管理界面，这个时候显示出三个项目（域名、外部访问端口、内部对外端口），其中域名是你自己申请的，外部访问端口是meibu给你分配的，内部对外端口是你电脑打算对外提供的端口，申请域名的时候系统默认给你的是80，这个时候因为你不是想对外提供WEB服务，而是想在外面连接SQL数据库，而SQL数据库的端口是1433，所以在这里你把80修改为1433。然后提交。 <br />4、 <br />运行你下载的“苹果茶”内网服务客户端软件； <br />5、 <br />在外网连接你内网SQL数据库时，请把连接的端口修改为每步提供给你的“外部访问端口”。 <br /><br />尝试一下，很容易就实现了。 <br />其实每步提供给你的“外部访问端口”就是一个端口映射，他帮助我们解决了不能在代理服务器或者路由器上做端口映射的困扰
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249285" style="color:red;">已有 <strong>4</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 12:02:23 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249285</link>
        <guid>http://www.javaeye.com/topic/249285</guid>
      </item>
          <item>
        <title>Hibernate缓存机制</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://yuanyao.javaeye.com">yuanyao</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249465" style="color:red;">http://www.javaeye.com/topic/249465</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <span style="color: red">缓存是位于应用程序与物理数据源之间，用于临时存放复制数据的内存区域，目的是为了减少应用程序对物理数据源访问的次数，从而提高应用程序的运行性能.<br />&nbsp; Hibernate在查询数据时，首先到缓存中去查找，如果找到就直接使用，找不到的时候就会从物理数据源中检索，所以，把频繁使用的数据加载到缓存区后，就可以大大减少应用程序对物理数据源的访问，使得程序的运行性能明显的提升.</span><br />&nbsp; <br /> <span style="color: red"> Hibernate缓存分类：</span><br /> <br /> Session缓存，一级缓存.<br /><br /> SessionFactory的缓存分为内置缓存和外置缓存.内置缓存中存放的是SessionFactory对象的一些集合属性包含的数据(映射元素据及预定义SQL语句等),对于应用程序来说,它是只读的.外置缓存中存放的是数据库数据的副本,其作用和一级缓存类似.二级缓存除了以内存作为存储介质外,还可以选用硬盘等外部存储设备.<br /><br /> <span style="color: red"> Hibernate的缓存范围</span><br /><br /> Hibernate的一级缓存和二级缓存都位于均位于持久层,且均用于存放数据库数据的副本,最大的区别就是缓存的范围各不一样.<br /> <br /> 缓存的范围分为3类:<br /><br /> 1.事务范围<br />&nbsp;&nbsp; 事务范围的缓存只能被当前事务访问,每个事务都有各自的缓存,缓存内的数据通常采用相互关联的对象形式.缓存的生命周期依赖于事务的生命周期,只有当事务结束时,缓存的生命周期才会结束.事务范围的缓存使用内存作为存储介质,一级缓存就属于事务范围.<br /> 2.应用范围<br />&nbsp;&nbsp; 应用程序的缓存可以被应用范围内的所有事务共享访问.缓存的生命周期依赖于应用的生命周期,只有当应用结束时,缓存的生命周期才会结束.应用范围的缓存可以使用内存或硬盘作为存储介质,二级缓存就属于应用范围.<br /> 3.集群范围<br />&nbsp;&nbsp; 在集群环境中,缓存被一个机器或多个机器的进程共享,缓存中的数据被复制到集群环境中的每个进程节点,进程间通过远程通信来保证缓存中的数据的一致,缓存中的数据通常采用对象的松散数据形式.<br /><br /><span style="color: red">&nbsp; Hibernate的缓存管理</span><br /><br /> <span style="color: blue"> 一级缓存的管理:</span><br /><br />&nbsp; <span style="color: red">evit(Object obj)</span>&nbsp; 将指定的持久化对象从一级缓存中清除,释放对象所占用的内存资源,指定对象从持久化状态变为脱管状态,从而成为游离对象.<br />&nbsp; <span style="color: red">clear()</span>&nbsp; 将一级缓存中的所有持久化对象清除,释放其占用的内存资源<br />&nbsp; <span style="color: red">contains(Object obj) </span> 判断指定的对象是否存在于一级缓存中.<br />&nbsp; <span style="color: red"> flush() </span> 刷新一级缓存区的内容,使之与数据库数据保持同步.<br /><br />&nbsp; <span style="color: blue">二级缓存的管理:</span><br />&nbsp;&nbsp; <br />&nbsp;&nbsp; <span style="color: red">evict(Class arg0, Serializable arg1)</span>&nbsp; 将某个类的指定ID的持久化对象从二级缓存中清除,释放对象所占用的资源.<br />&nbsp;&nbsp; <pre name="code" class="java">sessionFactory.evict(Customer.class, new Integer(1));</pre><br />&nbsp;&nbsp; <span style="color: red">evict(Class arg0)</span>&nbsp; 将指定类的所有持久化对象从二级缓存中清除,释放其占用的内存资源.<br />&nbsp;&nbsp; <pre name="code" class="java">sessionFactory.evict(Customer.class);</pre><br />&nbsp;&nbsp; <span style="color: red">evictCollection(String arg0)</span>&nbsp; 将指定类的所有持久化对象的指定集合从二级缓存中清除,释放其占用的内存资源.<br />&nbsp;&nbsp; <pre name="code" class="java">sessionFactory.evictCollection("Customer.orders");</pre><br /><br /><span style="color: red">Hibernate的二级缓存的配置</span><br /> <br />首先,不是所有的数据都适合放在二级缓存中,看一下,什么样的数据适合放在二级缓存中来?什么样的数据不适合放在二级缓存中来?<br />&nbsp; 下面这几种情况就<span style="color: red">不适合</span>加载到二级缓存中:<br />&nbsp; 1.经常被修改的数据<br />&nbsp; 2.绝对不允许出现并发访问的数据<br />&nbsp; 3.与其他应用共享的数据<br />&nbsp; 下面这己种情况<span style="color: red">合适</span>加载到二级缓存中:<br />&nbsp; 1.数据更新频率低<br />&nbsp; 2.允许偶尔出现并发问题的非重要数据<br />&nbsp; 3.不会被并发访问的数据<br />&nbsp; 4.常量数据<br />&nbsp; 5.不会被第三方修改的数据<br /><br />Hibernate的二级缓存功能是靠配置二级缓存插件来实现的,Hibernate为了集成这些插件,Hibernate提供了org.hibernate.cache.CacheProvider借口,它充当缓存插件与Hibernate之间的适配器 .<br /><br />常用的二级缓存插件<br />EHCache&nbsp; org.hibernate.cache.EhCacheProvider<br />OSCache&nbsp; org.hibernate.cache.OSCacheProvider<br />SwarmCahe&nbsp; org.hibernate.cache.SwarmCacheProvider<br />JBossCache&nbsp; org.hibernate.cache.TreeCacheProvider<br /><br />简单介绍一下EHCache的配置<br />hibernate.cfg.xml<br /> <pre name="code" class="xml"> &lt;hibernate-configuration>
    &lt;session-factory>
       &lt;!-- 设置二级缓存插件EHCache的Provider类-->
       &lt;property name="hibernate.cache.provider_class">
          org.hibernate.cache.EhCacheProvider
       &lt;/property>
       &lt;!-- 启动"查询缓存" -->
       &lt;property name="hibernate.cache.use_query_cache">
          true
       &lt;/property>
    &lt;/session-factory>
  &lt;/hibernate-configuration></pre><br /><br />ehcache.xml<br /><br /><pre name="code" class="xml">&lt;ehcache>
  &lt;!-- maxElementsInMemory为缓存对象的最大数目, eternal设置是否永远不过期,timeToIdleSeconds对象处于空闲状态的最多秒数,timeToLiveSeconds对象处于缓存状态的最多秒数 -->
  &lt;diskStore path="java.io.tmpdir"/>
    &lt;defaultCache maxElementsInMemory="10000" eternal="false"  timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true"/>
&lt;/ehcache>
</pre><br /><br />****.hbm.xml<br /><br /><pre name="code" class="xml">&lt;?xml version="1.0" encoding='UTF-8'?>
&lt;!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

&lt;hibernate-mapping>
     
   &lt;class>
       &lt;!-- 设置该持久化类的二级缓存并发访问策略 read-only read-write nonstrict-read-write transactional-->
       &lt;cache usage="read-write"/>    
   &lt;/class>

&lt;/hibernate-mapping>
</pre><br /><br />最近用上了,看看了,有什么不妥的地方,多谢指出.
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249465" style="color:red;">已有 <strong>2</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 16:29:32 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249465</link>
        <guid>http://www.javaeye.com/topic/249465</guid>
      </item>
          <item>
        <title>HTML&amp; Oracle特殊(敏感)字符处理</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://chhj-292.javaeye.com">chhj_292</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249478" style="color:red;">http://www.javaeye.com/topic/249478</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p><span style="font-size: medium;"><strong>问题描述：</strong></span></p>
<p>&nbsp;&nbsp;&nbsp; 做BS开发，免不了B/S交互，免不了接受客户端输入的各种字符，包括敏感字符（如：&lt;script type="text/javascript"&gt;alert("如果你没有屏蔽我，那可就危险了哦！");&lt;/script&gt;）。这就是敏感字符，如果页面的输出（或者客户端输入，要看具体项目，具体情况而行）没有进行处理，那么*&hellip;&hellip;*&hellip;&hellip;*&hellip;&hellip;&middot;￥*#&hellip;&hellip;*！！&middot;&middot;！...，大家都知道会发生什么情况。</p>
<p><span style="font-size: medium;"><strong>解决：</strong></span></p>
<p>&nbsp;&nbsp; 单个字符串的处理可能大家都有自己的一套，但是如果处理的参数是一个对象的，需要把对象里的字符串属性中的敏感字符用自定义的字符替换的话可能就不是那么方便了，我现在提供的方法就是包含了上述两种处理方式。</p>
<p>&nbsp;&nbsp;&nbsp; HtmlConverter继承一个抽象类（共有的初步实现）和一个接口（面对程序员的接口），中包含两个成员变量、方法和一个静态内部类（为什么使用<strong>私有静态内部类</strong>，大家可以查看其他方面的资料，不在赘述。）</p>
<p>&nbsp;&nbsp;&nbsp; OracleConverter和HtmlConverter类似，不在赘述。</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; ----单例对象（参数：当通过第归处理对象中包含的敏感字符时，指定的第归的层数，用于目标对象中的属性也是自定义数据类型的情况）</p>
<p>&nbsp;&nbsp;&nbsp; ----默认递归两层，如果不能满足要求，还有一个构造函数可以使用，不过最大注意其抛出的异常。</p>
<p>&nbsp;&nbsp;&nbsp; private final static AbsConverter&nbsp;&nbsp;&nbsp; converter&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = new HtmlConverter(2);</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; ----静态内部类，静态内部类中包含了所有html敏感字符，可以将敏感字符进行替换后在jsp获取其他客户端输出。</p>
<p>&nbsp;&nbsp;&nbsp; ----该静态内部类继承了一个回调借口。至于其用途和其他地方的回调类似，作用也一样。<br />&nbsp;&nbsp;&nbsp; private static ICallbackEncoder&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; callbackEncoder&nbsp;&nbsp;&nbsp; = new CallbackEncoder();</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; ----处理对象中属性的敏感字符。ignoreProperties表示需要忽略的属性。</p>
<p>&nbsp;&nbsp;&nbsp; public Object encoding(Object obj, String[] ignoreProperties)<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; throws InstantiationException, IllegalAccessException,<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; InvocationTargetException, IntrospectionException,<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; NullPointerException, ClassNotFoundException {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return super.encoding(obj, ignoreProperties, callbackEncoder);<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; ----处理单个字符串中的敏感字符</p>
<p>&nbsp;&nbsp;&nbsp; public String encoding(String _src) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (String) super.encoding(_src, callbackEncoder);<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; 代码如下：</p>
<pre name="code" class="java">/**
 * Copyright 2007 pantosoft. All rights reserved.
 */

package com.pantosoft.cmsnj.utils.converter;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;

/**
 * standard interface.
 * @author Cheng 2008-9-3 上午11:26:49
 * @version 1.0.0
 */
public interface IConverter {
	/**
	 * 
	 * @param _src
	 * @return
	 */
	public abstract Object encoding(String _src);

	/**
	 * 
	 * @param obj
	 * @param ignoreProperties
	 * @return
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws IntrospectionException
	 * @throws NullPointerException
	 * @throws ClassNotFoundException
	 */
	public abstract Object encoding(Object obj, String[] ignoreProperties)
			throws InstantiationException, IllegalAccessException,
			InvocationTargetException, IntrospectionException,
			NullPointerException, ClassNotFoundException;

}
</pre>
&nbsp;
<pre name="code" class="java">/**
 * Copyright 2008 pantosoft. All rights reserved.
 */

package com.pantosoft.cmsnj.utils.converter;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;

import com.pantosoft.cmsnj.utils.converter.callback.ICallbackEncoder;

/**
 * 
 * @author Cheng 2008-9-3 下午01:38:41
 * @version 1.0.0
 */
public class HtmlConverter extends AbsConverter implements IConverter {
	private final static AbsConverter	converter		= new HtmlConverter(2);
	private static ICallbackEncoder		callbackEncoder	= new CallbackEncoder();

	/**
	 * return a default unmodifiable html converter to convert invalid characters to html characters, and the default loop depth is 2.
	 * 
	 * @return
	 */
	public static AbsConverter getInstance() {
		return converter;
	}

	/**
	 * return a user-defined modifiable and specified depth of loop html converter
	 * @param depth loop depth.
	 */
	public HtmlConverter(int depth) {
		if (depth &lt; 1 || depth &gt; 5)
			throw new IllegalArgumentException(
					"the arguments of 'depth' must betwen 1 and 5");
		else
			this.defaultDepth = depth;
	}

	/*
	 * (non-Javadoc)
	 * @see com.pantosoft.edu.utils.converter.IConverter#encoding(java.lang.Object, java.lang.String[])
	 */
	public Object encoding(Object obj, String[] ignoreProperties)
			throws InstantiationException, IllegalAccessException,
			InvocationTargetException, IntrospectionException,
			NullPointerException, ClassNotFoundException {
		return super.encoding(obj, ignoreProperties, callbackEncoder);
	}

	/*
	 * (non-Javadoc)
	 * @see com.pantosoft.edu.utils.converter.IConverter#encoding(java.lang.String)
	 */
	public String encoding(String _src) {
		return (String) super.encoding(_src, callbackEncoder);
	}

	/**
	 * 
	 * @author Cheng 2008-10-6 下午04:11:16
	 * @version 1.0.0
	 */
	private static class CallbackEncoder implements ICallbackEncoder {
		public String convert(String _src) throws NullPointerException {
			if (_src == null)
				throw new NullPointerException(
						"value of parameter '_src' is null.");
			StringBuilder result = new StringBuilder();
			if (_src != null) {
				_src = _src.trim();
				for (int pos = 0; pos &lt; _src.length(); pos++) {
					switch (_src.charAt(pos)) {
						case '\"':
							result.append(""");
							break;
						case '&lt;':
							result.append("&lt;");
							break;
						case '&gt;':
							result.append("&gt;");
							break;
						case '\'':
							result.append("'");
							break;
						case '&amp;':
							result.append("&amp;");
							break;
						case '%':
							result.append("&amp;pc;");
							break;
						case '_':
							result.append("&amp;ul;");
							break;
						case '#':
							result.append("&amp;shap;");
							break;
						case '?':
							result.append("&amp;ques;");
							break;
						default:
							result.append(_src.charAt(pos));
							break;
					}
				}
			}
			return result.toString();
		}
	}
}
</pre>
<p>
<strong><span style="font-size: medium;">&nbsp;
说明：</span></strong></p>
<p>　　　　其实这种敏感字符的解决方法很多而且前人已早有实现，我这里提供的这种方法无非是自己为了减轻自己的工作量而实现的一种方法，我是做教育系统的开发的，一般按照GB一个学生的直接属性有大概50种，而且又不得不在一个JSP上展示，所以我就干脆将得到的学生对象一次性处理。</p>
<p>&nbsp;</p>
<p><strong>　　　　懒惰，也不失一种写代码的艺术。</strong></p>
<p>　　　　代码全部打包上传，欢迎大家批评指正，不过都有Copyright（版权）和@author（作者）的，大家修改代码和转载的时候务必保留这些信息。</p>
<p>　　　　最近发现此地气氛很浮躁，到处都是喷水的。大家还是静下心来做事情吧。</p>
<p>　　　　代码注释较少，但是必要的注释还是都有的，不明白的可以在这里提问，相互学习。</p>
<p>　　　　<strong>在开源的世界里，我们喜欢更多的源码。</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249478" style="color:red;">已有 <strong>0</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 16:57:03 +0800</pubDate>
        <link>http://www.javaeye.com/topic/249478</link>
        <guid>http://www.javaeye.com/topic/249478</guid>
      </item>
          <item>
        <title>基于spring与hibernate的通用分页实现</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://iorn-gu.javaeye.com">iorn.gu</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/248322" style="color:red;">http://www.javaeye.com/topic/248322</a>&nbsp;
          发表时间: 2008年10月01日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          最近做了个分页..&nbsp; 拿出来大家讨论一下.<br /><br />先看一下效果.<br />在HTML代码:<br />js框架用的是jQuery. table函数是我自己做的一个表格插件.<br /><pre name="code" class="html">
&lt;#import "/spring.ftl" as spring/>
&lt;#import "/shop.ftl" as shop/>
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
&lt;html>
  &lt;head>
  	&lt;title>Data Table Demo&lt;/title>
  &lt;/head>
  &lt;body>
  	&lt;script>
  		$(function(){
  			$('.table4').table({
  				headers : ['&lt;@spring.message code="profile.detail.title"/>'],
  				data_columns : ['name'],
  				data_key: 'data',
  				data_url : $.root_ctx + '/demo/table3.htm',
  				pageable: true,
  				ajaxPager: true,
  				pageSize: 6
  			});
  			
  		});
  	&lt;/script>
  	&lt;div style="width: 90%">
  	&lt;@shop.panel height=245>
  		&lt;table class="table4" border="0" cellspacing="0" cellpadding="0">&lt;/table>
  	&lt;/@shop.panel>
  	&lt;/div>
  &lt;/body>
&lt;/html>
</pre><br /><br />再看controller里.<br /><pre name="code" class="java">
@Controller
public class DemoController extends BaseController{
	
	private ShopService shopService = null;
	
	@Autowired
	public void setShopService(ShopService shopService) {
		this.shopService = shopService;
	}

	@RequestMapping("/demo/table3.htm")
	public String testTable3(HttpServletRequest request,ModelMap map) {
		Object o = doPage(request, map, new PagerExecutor() {
			@Override
			public List&lt;?> doInPager(Pager pager) {
				return shopService.list();
			}
		});
		map.addAttribute("data", escapeForJson(o));
		return JSON;
	}
}
</pre><br /><br />service里的list方法实现<br /><pre name="code" class="java">
	@Override
	//@Exclude("BaseDao.list")
	public List&lt;Shop> list() {
		return shopDao.list();
	}
</pre><br /><br />dao里的list方法实现<br /><pre name="code" class="java">
	@SuppressWarnings("unchecked")
	@Override
	public List&lt;T> list() throws DataAccessException {
		return getHibernateTemplate().loadAll(clazz);
	}
</pre><br /><br /><span style="font-size: large"><strong>到现在. 分页相关的代码已经写完了. <br />可以看到. service与dao里没有任何与分页有关的代码.<br />接下来看下实现分页相关的东西.</strong></span><br /><br />Pager接口<br /><pre name="code" class="java">
/**
 * @author Iorn.Gu
 */
public interface Pager {

	boolean isEnabled();
	
	void setPageSize(int pageSize);
	int getPageSize();
	
	void setCurrentPage(int currentPage);
	int getCurrentPage();
	
	void setFetchCount(boolean fetchCount);
	
	PagerResult execute(PagerExecutor executor);
}
</pre><br /><br />实现类<br /><pre name="code" class="java">
public class PagerImpl implements Pager{

	private boolean enabled = false;
	private boolean fetchCount = false;
	private int pageSize = 10;
	private int currentPage = 0;
	
	private static final Object LOCK = new Object();
	
	@Override
	public PagerResult execute(PagerExecutor executor) {
		synchronized (LOCK) {
			PagerResult result = new PagerResult();
			if( fetchCount || currentPage &lt; 0) {
				enabled = false;
				List&lt;?> re = executor.doInPager(this);
				result.setItemCount(re.size());
				fetchCount = false;
			} else if( currentPage != 0 ){
				enabled = true;
				List&lt;?> re = executor.doInPager(this);
				result.setPageItems(re);
				enabled = false;
			}
			currentPage = 0;
			return result;
		}
	}

	@Override
	public void setCurrentPage(int currentPage) {
		synchronized (LOCK) {
			if( !isEnabled() )
				this.currentPage = currentPage;
		}
	}

	@Override
	public void setPageSize(int pageSize) {
		synchronized (LOCK) {
			if( !isEnabled() )
				this.pageSize = pageSize;
		}
	}

	@Override
	public int getCurrentPage() {
		return currentPage;
	}

	@Override
	public int getPageSize() {
		return pageSize;
	}

	@Override
	public boolean isEnabled() {
		return enabled;
	}

	public void setFetchCount(boolean fetchCount) {
		this.fetchCount = fetchCount;
	}
	
}
</pre><br /><br />PagerResult <br /><pre name="code" class="java">
public class PagerResult {

	private int itemCount = 0;
	private List&lt;?> pageItems = null;
	
	public int getItemCount() {
		return itemCount;
	}
	
	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}
	
	public List&lt;?> getPageItems() {
		return pageItems;
	}
	
	public void setPageItems(List&lt;?> pageItems) {
		this.pageItems = pageItems;
	}
	
}
</pre><br /><br />PagerExecutor <br /><pre name="code" class="java">
public interface PagerExecutor {

	List&lt;?> doInPager(Pager pager);
	
}
</pre><br /><br />PageableHibernateTemplete类.<br />关于PagerMethodExcludeHolder 这个类相关的东西.到最后再说吧.先忽略.! 只看两个prepare方法.<br /><pre name="code" class="java">
public class PageableHibernateTemplete extends HibernateTemplate {

	private Pager pager = null;
	private PagerMethodExcludeHolder excludeHolder = null;
	
	public PageableHibernateTemplete(SessionFactory sessionFactory) {
		super(sessionFactory);
	}
	
	@Autowired
	public void setPager(Pager pager) {
		this.pager = pager;
	}

	@Autowired
	public void setExcludeHolder(PagerMethodExcludeHolder excludeHolder) {
		this.excludeHolder = excludeHolder;
	}

	@Override
	protected void prepareCriteria(Criteria criteria) {
		if( pager.isEnabled() && !isMethodExcluded()) {
			criteria.setFirstResult((pager.getCurrentPage()-1)*pager.getPageSize());
			setMaxResults(pager.getPageSize());
		} else {
			criteria.setFirstResult(0);
			setMaxResults(0);
		}
		super.prepareCriteria(criteria);
	}

	@Override
	protected void prepareQuery(Query queryObject) {
		if( pager.isEnabled() && !isMethodExcluded() ) {
			queryObject.setFirstResult((pager.getCurrentPage()-1)*pager.getPageSize());
			setMaxResults(pager.getPageSize());
		} else {
			queryObject.setFirstResult(0);
			setMaxResults(0);
		}
		super.prepareQuery(queryObject);
	}
	
	private boolean isMethodExcluded() {
		String[] excludeds = excludeHolder.getExcludeMethods();
		if( excludeds != null ) {
			StackTraceElement[] elements = (new Throwable()).getStackTrace();
			boolean inDao = false;
			for( StackTraceElement element : elements ) {
				if( element.getClassName().endsWith("DaoImpl") ) {
					inDao = true;
					for( String excluded : excludeds ) {
						String method = excluded.substring(excluded.lastIndexOf(".")+1);
						String prefix = excluded.substring(0,excluded.lastIndexOf("."));
						if( element.getMethodName().equals(method) && element.getClassName().indexOf(prefix) != -1 ) {
							System.out.println("exlucde Method:" + element.getClassName() + "." + element.getMethodName());
							return true;
						}
					}
				} else if( inDao ){
					break;
				}
			}
		}
		return false;
	}
	
}
</pre><br /><br />然后是BaseController类的doPager(在上面的controller那块里头用到)方法.<br /><pre name="code" class="java">
	@SuppressWarnings("unchecked")
	protected List&lt;?> doPage(HttpServletRequest request,Map model,PagerExecutor executor) {
		String getItemCount = request.getParameter("getItemCount");
		String currentPage = request.getParameter("currentPage");
		String pageSize = request.getParameter("pageSize");
		
		if( "true".equals(getItemCount) ) {
			pager.setFetchCount(true);
			PagerResult result = pager.execute(executor);
			model.put("itemCount", result.getItemCount());
			return null;
		} else if( currentPage != null && !"".equals(currentPage) ) {
			int curr = Integer.parseInt(currentPage);
			pager.setCurrentPage(curr);
			if( pageSize != null && !"".equals(pageSize) ) {
				int ps = Integer.parseInt(pageSize);
				pager.setPageSize(ps);
			}
		} else {
			pager.setCurrentPage(-1);
		}
		PagerResult result = pager.execute(executor);
		
		return result.getPageItems();
	}
</pre><br /><br />最后就是那个jQuery的table插件了.. 代码太长. 就只贴取数据那一段了.<br /><pre name="code" class="javascript">
var AjaxPageableDataModel = function(config){
		var param = $.extend({},config.data_param);
		$.extend(param,{'getItemCount':true});
		
		$.ajax({
			async : false,
			url : config.data_url,
			data : param,
			type : 'POST',
			cache : true,
			success : function(data){
				config.itemCount = eval('('+data+')').itemCount;
			}
		});
		param['getItemCount'] = false;
		
		config.pageCount = parseInt(config.itemCount / config.pageSize);
		config.pageCount += ((config.itemCount % config.pageSize == 0) ? 0 : 1)
		
		return {
			getData : function(curPage){
				config.currentPage = curPage ? curPage : 1;
				param['currentPage'] = config.currentPage;
				param['pageSize'] = config.pageSize;
				
				var result = false;
				$.ajax({
					async : false,
					url : config.data_url,
					data : param,
					type : 'POST',
					success : function(data){
						result = eval('('+data+')');
					}
				});
				return (result && result[config.data_key]) ? result[config.data_key] : [];
			},
			getPageCount : function(){
				return config.pageCount;
			},
			getItemCount : function(){
				return config.itemCount;
			}
		}
	};
</pre><br /><br />就这些了. 虽然没写注释,但应该不难看懂.<br /><br />然后还有PagerMethodExcludeHolder类没有贴.. 这个要说明一下. <br />因为在service层的方法里. 有可能会调用多个dao的方法. 而dao的方法并不是每一个都要分页处理. 这时就要用到这个类相关的东西了.<br />在上面的service方法里. 注释了一行@Exclude("BaseDao.list"). 这行表示.BaseDao里的list方法不需要做分页处理.<br />下面是这些东西的代码.<br /><br /><pre name="code" class="java">
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Exclude {

	String[] value() default {};
	
}
</pre><br /><br /><pre name="code" class="java">
@Aspect
public class PagerMethodExcludeHolder {

	private Map&lt;Method, String[]> methodCache = new HashMap&lt;Method, String[]>();
	private String[] excludeMethods = null;
	
	@Around("execution(public java.util.List *..*service..*.*(..)) and @annotation(com.guyong.common.pager.Exclude)")
	public Object whenPager(ProceedingJoinPoint joinPoint) throws Throwable {
		Method method = getCurrentMethod(joinPoint);
		if( !methodCache.containsKey(method) ) {
			Exclude exclude = AnnotationUtils.findAnnotation(method, Exclude.class);
			String[] excludes = null;
			if( exclude != null ) {
				excludes = exclude.value();
			}
			methodCache.put(method, excludes);
		}
		excludeMethods = methodCache.get(method);
		Object result = joinPoint.proceed();
		excludeMethods = null;
		return result;
	}
	
	private Method getCurrentMethod(ProceedingJoinPoint joinPoint) {
		Signature s = joinPoint.getSignature();
		Class&lt;?> clazz = joinPoint.getTarget().getClass();
		Method getMethod = ReflectionUtils.findMethod(s.getClass(), "getMethod");
		ReflectionUtils.makeAccessible(getMethod);
		Method tmp = (Method)ReflectionUtils.invokeMethod(getMethod, s);
		Class&lt;?>[] argTypes = tmp.getParameterTypes();
		return ReflectionUtils.findMethod(clazz, s.getName(), argTypes);
	}

	public String[] getExcludeMethods() {
		return excludeMethods;
	}
	
}
</pre><br /><br />好了..&nbsp; 欢迎大家批评指教.<br />附件里是效果图跟每页数据的返回值..
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/248322" style="color:red;">已有 <strong>11</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Wed, 01 Oct 2008 01:22:00 +0800</pubDate>
        <link>http://www.javaeye.com/topic/248322</link>
        <guid>http://www.javaeye.com/topic/248322</guid>
      </item>
          <item>
        <title>关于支持unpack相关的一些 gem</title>
        <author>JavaEye网站</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://sina2009.javaeye.com">sina2009</a>&nbsp;
                    链接：<a href="http://www.javaeye.com/topic/249469" style="color:red;">http://www.javaeye.com/topic/249469</a>&nbsp;
          发表时间: 2008年10月06日
          <br/>
          声明：本文系JavaEye网站发布的原创文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          在开发rails的过程中,我想将所有程序依赖的gem 都unpack到项目 vendor 的目录中<br /><br />比如:<br /><br />&nbsp; config.gem "xml-simple"<br />&nbsp; config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"<br /><br />但不知道咋的无法unpack xml-simple,提示 "no such file to load -- xml-simple"<br /><br />不知道是为什么,我估计是xml-simple的用法是require 'xmlsimple'<br /><br />这种情况不知如何处理<br /><br /><br />另外哪些gem才支持unpack,怎么看出来<br /><br />谢谢
          <br/><br/>
          <span style="color:red;">
            <a href="http://www.javaeye.com/topic/249469" style="color:red;">已有 <strong>0</strong> 人发表回复，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">Windows7在微软WinHEC 2008上揭开神秘面纱</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 06 Oct 2008 16:37:37 +0800</pubDate>
        <li