一个nested exception问题

一个hibernate报的异常:nested exception is org.hibernate.QueryException: could not resolve property困扰了我好一阵。

原来是因为hibernate对象不能多层嵌套查询,比如:
dc.add(Restrictions.eq(“wdxcAddressbookClass.wdxcUser.id”,ownerId));
改为:
dc.add(Restrictions.sqlRestriction(“{alias}.classid in (select id from wdxc_addressbook_class where ownerid=?)”,ownerId,Hibernate.LONG));
之后就可以了

顺便把前几天遇到的一个问题也记录一下:

环境是jsf+spring+hibernate,由于页面还没设计好,后台业务处理部分已经写好了,想测试一下,就做了一个测试jsp页面
异常信息:could not initialize proxy – the owning Session was closed
解决方法一:
[java]
public WdxcAddressbook getAddressbookByID(Serializable id) {
WdxcAddressbook addressbook =(WdxcAddressbook)dao.load(WdxcAddressbook.class,id);
//System.out.println(addressbook.getId());
return addressbook;
}
[/java]
在spring接口实现类中获取一下对象,就是上面注释掉的
解决方面二:
在web.xml中把.jsp页面也添加到hibernate的filter-mapping
原因:原来jsf的hibernate filter处理的都是.faces的页面,没有处理.jsp的页面,而且hibernate数据库实际获取操作是在用户实际获取值的时候发生的,所以需要filter把session延迟到jsp页面中

2,973人评论了“一个nested exception问题”

  1. We are a group of volunteers and opening a brand new scheme in our community. Your website provided us with useful info to work on. You have done an impressive activity and our whole neighborhood will probably be thankful to you.|

  2. Thanks for your personal marvelous posting! I genuinely enjoyed reading it, you can be a great author.I will make certain to bookmark your blog and will come back later on. I want to encourage you to definitely continue your great posts, have a nice morning!|

  3. Fantastic goods from you, man. I’ve understand your stuff previous to and you are just too wonderful. I really like what you have acquired here, certainly like what you are stating and the way in which you say it. You make it enjoyable and you still take care of to keep it wise. I can not wait to read far more from you. This is really a wonderful web site.|

  4. May I simply say what a comfort to discover somebody who really knows what they’re talking about online. You certainly understand how to bring an issue to light and make it important. A lot more people ought to read this and understand this side of the story. I was surprised you’re not more popular because you definitely have the gift.|

  5. Thank you so much for giving everyone remarkably pleasant chance to discover important secrets from this site. It is often so useful and as well , full of a good time for me and my office acquaintances to search your blog minimum three times a week to read through the new stuff you have got. Of course, I’m also usually fulfilled concerning the outstanding thoughts served by you. Selected 2 ideas in this article are in fact the most suitable we have had.

  6. I in addition to my guys happened to be checking out the good solutions from your web page then the sudden came up with a terrible feeling I had not expressed respect to the site owner for those tips. Those young men are actually consequently stimulated to see all of them and have in effect surely been tapping into them. We appreciate you indeed being very considerate as well as for pick out such cool guides most people are really wanting to understand about. My very own honest apologies for not saying thanks to you earlier.

  7. I’m really enjoying the design and layout of your site. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to create your theme? Superb work!|

  8. I’m extremely impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it’s rare to see a nice blog like this one nowadays.|

  9. Write more, thats all I have to say. Literally, it seems as though you relied
    on the video to make your point. You definitely know
    what youre talking about, why throw away your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

  10. I’m really enjoying the design and layout of your website. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a designer to create your theme? Fantastic work!|

发表评论

电子邮件地址不会被公开。 必填项已用*标注