??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
假设有两个表QPhotos(一Q?--- picture(多)Photo包含picture集合
l论1Q?HQL代码 > fetchQ配|) > lazy Q配|)
l论2Q?默认 lazy="true"
l论3Q?fetch ?lazy 主要是用来联查询的Q ??cascade ?inverse 主要是用来联插入和修改?br />l论4Q?如果你是用spring来帮你管理你的session, q且是自动提交,延迟加蝲q于没加蝲~_~(当然
除非你手动重新打开session然后手动Hibernate.initialize(set);然后关闭session.
l论5: cascade主要是简化了在代码中的联更新和删除?br />jl论6Q老爸可以有多个孩子,一个孩子不能有多个老爸Q而且老爸说的? 孩子围着老爸转?br /> 所以Photos老爸要有权力所?cascade q个关键子都是送给老爸的, 也就是联更斎ͼ
老爸改姓了,儿子也得跟着改,呵呵。“不Ӟ没有零花钱咯”?br /> 而Picture儿子整体挨骂Q但是还是要l护父子之间良好的关p,对老爸百依NQ所
以老爸pQ儿子,“关p,׃来维护(inverse="true") Q不然就不给零花钱。呵。”?br /> <set name="pictures" inverse="true" cascade="all">
<key>
<column name="photosid" not-null="true" />
</key>
<one-to-many class="girl.domain.Picture" />
</set>
试代码Q?br />
Photos p = ps.getById(1);
Set<Picture> set = p.getPictures();
for(Picture pic : set){
System.out.println(pic.getId());
}
配置文g的一部分Q?br /> <set name="pictures" inverse="true" cascade="all" >
<key>
<column name="photosid" not-null="true" />
</key>
<one-to-many class="girl.domain.Picture" />
</set>
试q程会对配置文g不断修改Qƈ且从来不曾手动重新打开session
试l构Q?br />
当配|条件ؓ lazy=true 一句查?试代码中没有调用getPicture() 正常
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
lazy=true 一句查?有getPicture()
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
lazy=true 一句查询?有getPicture() q且讉K了里面的元数Picture 且有异常抛出
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
lazy="false" 两句查询 肯定没问题,因ؓ全部数据都个查了出来 所以怎么调用都正?br />Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
Hibernate: select pictures0_.photosid as photosid1_, pictures0_.id as id1_, pictures0_.id as id2_0_, pictures0_.photosid as photosid2_0_, pictures0_.name as name2_0_, pictures0_.clicked as clicked2_0_, pictures0_.uploaddate as uploaddate2_0_, pictures0_.size as size2_0_, pictures0_.description as descript7_2_0_, pictures0_.uri as uri2_0_ from super.picture pictures0_ where pictures0_.photosid=?
fetch="join" 一句查询?效果 Q= lazy="false" 呵呵Q哪个效率高Q我׃知道了。。。。。。。。。。?br />Hibernate: select photos0_.id as id0_1_, photos0_.userid as userid0_1_, photos0_.typeid as typeid0_1_, photos0_.name as name0_1_, photos0_.createtime as createtime0_1_, photos0_.description as descript6_0_1_, photos0_.faceid as faceid0_1_, photos0_.uri as uri0_1_, pictures1_.photosid as photosid3_, pictures1_.id as id3_, pictures1_.id as id2_0_, pictures1_.photosid as photosid2_0_, pictures1_.name as name2_0_, pictures1_.clicked as clicked2_0_, pictures1_.uploaddate as uploaddate2_0_, pictures1_.size as size2_0_, pictures1_.description as descript7_2_0_, pictures1_.uri as uri2_0_ from super.photos photos0_ left outer join super.picture pictures1_ on photos0_.id=pictures1_.photosid where photos0_.id=?
不加fetchQ?join" 一句查询?没有getPicture() 正常
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
不加fetchQ?join" 一句查询?有getPicture() 正常
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
不加fetchQ?join" 一句查?有getPicture() q且讉K里面的元素Picture的ID 有异常抛?br />Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
来个两兵交战 fetch="join" lazy="true" 呵呵 l果Q一句查询, l构正常 所以就当lazy不存在好了?看来fetch 是老大。、、、、、、、、、、、、?br />Hibernate: select photos0_.id as id0_1_, photos0_.userid as userid0_1_, photos0_.typeid as typeid0_1_, photos0_.name as name0_1_, photos0_.createtime as createtime0_1_, photos0_.description as descript6_0_1_, photos0_.faceid as faceid0_1_, photos0_.uri as uri0_1_, pictures1_.photosid as photosid3_, pictures1_.id as id3_, pictures1_.id as id2_0_, pictures1_.photosid as photosid2_0_, pictures1_.name as name2_0_, pictures1_.clicked as clicked2_0_, pictures1_.uploaddate as uploaddate2_0_, pictures1_.size as size2_0_, pictures1_.description as descript7_2_0_, pictures1_.uri as uri2_0_ from super.photos photos0_ left outer join super.picture pictures1_ on photos0_.id=pictures1_.photosid where photos0_.id=?
<iframe width="145" height="130" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="<br><br><br><br>
<iframe ALIGN='center' src="<br><br><br><br>
<IFRAME ID='ifm1' WIDTH='405' HEIGHT='332' ALIGN='center' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC=">
<br><br><br>
<iframe width=160 height=230 frameborder=0 ALIGN='center' scrolling=NO src=http://appnews.qq.com/cgi-bin/news_qq_search?city=q州></iframe>
<br><br><br>
<iframe width="469" height="218" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="<br><br>
<IFRAME ID='ifm1' WIDTH='260' HEIGHT='70' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' src=">
效果如下Q?br />
对jsf目的支持,sun creator 无疑lh一U?耳目一新的感觉Q?br />他对可视化开发的支持真的开始可以和.Net较劲了?/p>
但是 creator 有个问题是可以把项目部|到 sun app server的项目部|到其他服务器老是出同L问题Q?br />
下面ȝ一下:
步骤一: 把项目导出成 *.war文g
步骤? ?.war拯到其他服务器的部|目?br /> 比如 tomcat/resin ?webapp?br />步骤? q行服务?tomcat/resin) 问题来了,出现异常
[10:41:34.828] java.lang.NullPointerException
[10:41:34.828] at javax.faces.webapp.FacesServlet.init(FacesServlet.java:144)
[10:41:34.828] at com.caucho.server.dispatch.ServletConfigImpl.createServletImpl(ServletConfigImpl.java:646)
[10:41:34.828] at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:587)
看到q个"FacesServlet.java:144" 开始我怀疑是sun 的包的问? |上google和baidu了一?没搜到相关问题的解决办法.
最后在一个朋友的帮助下在web.xml文g里加了个Listener:
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
?q真?
心得如下:
在用workshop或者myeclipse用myfaces包徏jsf目?我们不会到cM的问?
因ؓ工具已经在web.xml里面加了listener:
<listener>
<!-- Listener, that does all the startup work (configuration, init). -->
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener </listener-class>
</listener>
但是如果用这些工L sun jsf 包时p手动listerner.(?步骤?
l大家个q接: sun creator的教E?从这里开始学jsf感觉比较全面:
http://gceclub.sun.com.cn/prodtech/javatools/jscreator/learning/tutorials/index.html
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
insert into topic(title,content) values('title1','content1')
create table review(
id int primary key identity(1,1),
topicid int references topic(id),
content text,
posttime datetime default getdate()
)
insert into review(topicid,content) values(1,'reice1')
insert into review(topicid,content) values(1,'reice1')
insert into review(topicid,content) values(2,'reice1')
insert into review(topicid,content) values(2,'reice1')
insert into review(topicid,content) values(2,'reice1')
insert into review(topicid,content) values(3,'reice1')
insert into review(topicid,content) values(3,'reice1')
insert into review(topicid,content) values(3,'reice1')
insert into review(topicid,content) values(3,'reice1')
insert into review(topicid,content) values(4,'reice1')
select t.id,t.title,t.content,r.newposttime from topic as t inner join (select max(posttime) as newposttime, topicid from review group by topicid) as r on t.id=r.topicid
q些是测试数?sqlserver2000试通过
看了AJAX基础教程,感觉不错,但是在向服务器传递参数的时候L会有让我感到苦恼的问?
比如下面的代?
<SCRIPT type="text/javascript">
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(Sid){
createXMLHttpRequest();
xmlHttp.open("GET","/CountServlet?Sid="+Sid,true);
xmlHttp.send(null);
}
</SCRIPT>
在服务端的CountServlet的doGet()Ҏ在多ơ请求之间只会被调用一?痛苦!!!(N是异步的问题...)
于是我又改了一下xmlHttp的openҎ的参数如?
xmlHttp.open("POST","/CountServlet,true)
xmlHttp.send("Sid="+Sid);
l果在服务器端的doPost()Ҏ在每ơ请求都会被正常调用,但是,request.getPrameter("Sid")Ҏ是怎么也获得不到参数Sid,
在高手的帮助?我又再次改了代码,如下:
xmlHttp.open("POST","/CountServlet?Sid="+Sid,false);
xmlHttp.send(null);
?q真?牙好,胃口好,入口见效,doPost()Ҏ能正常被调用,参数也传得到,具体是什么原?我还在学习之?..
8.19日加Q?br />解决办法Q?br />除了高手回复的方?q有一U解军_法就?
xmlHttp.open("GET","/CountServlet?Sid="+Sid+"&timeStamp="+new Date().getTime(),false);
xmlHttp.send(null);
同样是解决缓存的问题..