博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
周报2017.7.3-2017.7.7
阅读量:4280 次
发布时间:2019-05-27

本文共 1641 字,大约阅读时间需要 5 分钟。

   一些数据库相关Exception的解决方法:

    1.Could not locate gettermethod for property......

      原因:一些属性的getset方法的名字(大小写)与字段不对应,或者与数据库字段不对应。

            boolean类的get方法,若字段名前两个字母为is,则自动生成的get方法与字段名相同,也会出此错误。

    2.mysql workbench可连上服务器的数据库,在首页的MySQL Connection旁边点+添加即可

    3.DateLong类型转换

       Date date = newDate() //当前时间

       Long timestamp =  date.getTime();//转换成long

    4.数据库中间件的使用

    5.org.hibernate.hql.internal.ast.QuerySyntaxException: ...is not mapped

      hql语句中表名和字段名需与实体类类名和属性名相同,而不是与数据库中的表名和字段名相同,因为hql语句相对于sql语句是面向对象的。一般数据库表名字段名与实体类类名属性名只有大小写的区别,但是要特别注意他们之前有区别的情况(比如多或少了某些单词)。

    6.could not resolve property: ...of : ...

      hql语句中关联查询写错了,或者字段不对应。

    7.org.hibernate.hql.LazyInitializationException: failed to lazily initialize a collection of role : ... , could notinitialize proxy - no Session

      session已关闭,需在设置ManyToOne外键关联处将lazy设为false

    8.Column ... cannot be null

      将此 Column not null 属性勾选去掉。

    9.org.hibernate.HibernateException:null indexcolumn for collection: ...

      set代替List

    10.java.lang.IlleglArgumentException:id toload is required for loading

      使用类似get(id)的查询时,对传入的id进行非空校验。

    11.JSON.toJSONString()之后出现$ref字段,前端无法解析,无法显示数据

      方法1: 比如$ref指向某个parent父节点

         调用JSON.toJSONString()时传入 SerializerFeature.DisableCircularReferenceDetect来禁用$ref

                 此时,有可能会出现java.lang.StackOverflowError

                 现象:循环 at com.alibaba.fastjson.serializer.CollectionSerializer.write...

                     可能存在重复引用或者循环引用(参考http://blog.csdn.net/z714359830/article/details/51527066)

                     也可能是一对多双向关系导致,需改代码,将数据库一些双向关联改为单向(http://www.cnblogs.com/zhujiabin/p/6132951.html)等。

          方法2: 比如$ref指向另一个表对该表的引用

           是一对多双向关系导致,将数据库一些双向关联改为单向,或者加@JSONField(serialize =false)(http://www.cnblogs.com/zhujiabin/p/6132951.html)

          方法3: 前台解析$ref

              参考https://www.npmjs.com/package/fastjson_ref_resolver

            

      

 

你可能感兴趣的文章
copy constructor
查看>>
Some interesting facts about static member functions in C++
查看>>
ubuntu 如何上ptt
查看>>
C++ Can't Overload Static Function with Non-Static Function
查看>>
conversion constructor
查看>>
malloc() vs new
查看>>
What is the use of having destructor as private?
查看>>
type-cast operator
查看>>
When do we use Initializer List in C++?
查看>>
‘this’ pointer in C++
查看>>
scp command
查看>>
To Install Android Studio in Ubuntu 16.04 and Ubuntu 17.04
查看>>
how to extract code of apk file
查看>>
android 相關網址
查看>>
動態開關android log level
查看>>
how to mount /system as read/write in android?
查看>>
Android 線上的opengrok
查看>>
Android 好的文章網誌
查看>>
vim 常用指令
查看>>
Glib相關
查看>>