分类: Hibernate预览模式: 普通 | 列表
07-09
04

could not resolve property

org.hibernate.QueryException could not resolve property userid of com.xxx.yyy.Pay

使用到外键userid的时候,必须使用userinfo.userid方法才能得到。

=========================================
javax.naming.NameNotFoundException Name hibernate_connection_factory is not bound in this Context
原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。
例如many-to-one设置了以后,仍然在其中设置相冲突的property属性。

查看更多...

Tags: Exception

分类:Hibernate | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 4265
07-08
26

多选判断查询

竟然弄了好几个小时,查错。。。服了
先把错误的列出来:    
    public String countChoose(String name, String cid, String state) { //选择算法
        int lable = 0; //跟踪标记
        String sqladd = ""; //动态生成的sql部分语句
        String sql = "";
      
       if (!name.equals("")) {
            sqladd = "p.name='" + name + "'";//这里也需要注意,单引号

查看更多...

Tags: 查询 搜索

分类:Hibernate | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 739
07-08
25

根据分类查商品,一对多关系

方法如下:
public List getPtsByCateID(CategoryVO cate)
    {
        Transaction tx = null;
        List list =null;
        Session session = HibernateUtil.getSession();
        try {
            tx = session.beginTransaction();
            list =session.find("from ProductVO as p where p.cate="+cate.getId()+"");

查看更多...

分类:Hibernate | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 722
07-08
24

exception setting property value with CGLIB set 错误

今天做商城购物的时候,再原有表基础上加了一个double类型的字段,抛出了这个异常:
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of...
原因:查询结果中包含null的项  对于一些数字项包含null,定义该项时必须使用wrapper类型,而不能是primitive类型,例如使用Integer等,而不能是int否则会抛出exception!
解决:映射为int,double的字段,在建表时,某些int或者double字段的default 0,导致exception setting property value with CGLIB setter 这些字段出错.这些字段最后都有默认值.设置好默认值问题就可以解决了。

查看更多...

Tags: Exception CGLIB

分类:Hibernate | 固定链接 | 评论: 1 | 引用: 0 | 查看次数: 2018
07-08
22

ObjectNotFoundException: No row with the given ide

郁闷了好久,终于在goole上找到了错误原因
ObjectNotFoundException: No row with the given identifier exists
Where it can occur:

This might occur if you try to load a non-proxied object with session.load() or you load a proxied object and later access the proxy. It may also occur when loading mapped collections which are not eagerly fetched.
What it means:

This means just what it says - Hibernate expected to have a row with a certain id in the database, and did however not find it.
How it can be caused:

查看更多...

分类:Hibernate | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 878
错误提示如下:
引用内容 引用内容
IDENTITY_Insert 设置为 OFF 时,不能向表 'ORDERS' 中的标识列插入显式值。
Could not synchronize database state with session


我估计是关联关系造成。但弄了半天没弄好,最后只好
Drop TABLE orDERS
GO
好在是测试时的项目。。。
然后再建表

查看更多...

分类:Hibernate | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1234