Null value was assigned to a property of primitive
989 ワード
Exception: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.seven.domain.Book.printTime理由:データベース内のprintTimeフィールドがNULL Javaコードである
このタイプはhibernateタイプであり、生成されたBookクラスではprintTimeフィールドはlongタイプであり、基本タイプであり、NULLではない.解決方法:1つ目は、データベースフィールドが空に設定されていないことです.2つ目は、マッピングファイルを手動で変更し、printTimeはJavaタイプLong、すなわちtype=「java.lang.Long」を使用し、BookクラスのフィールドもLongに変更します.同様にintはIntegerである.3つ目は、hibernateタイプではなく、リバースエンジニアリングでJavaタイプを使用することです.
<!--Hibernate -->
<property name="printTime" type="long"><column name="print_time"/></property>
[java] view plaincopyprint?
<!--Hibernate -->
<property name="printTime" type="long"><column name="print_time"/></property>
<!--Hibernate -->
<property name="printTime" type="long"><column name="print_time"/></property>
このタイプはhibernateタイプであり、生成されたBookクラスではprintTimeフィールドはlongタイプであり、基本タイプであり、NULLではない.解決方法:1つ目は、データベースフィールドが空に設定されていないことです.2つ目は、マッピングファイルを手動で変更し、printTimeはJavaタイプLong、すなわちtype=「java.lang.Long」を使用し、BookクラスのフィールドもLongに変更します.同様にintはIntegerである.3つ目は、hibernateタイプではなく、リバースエンジニアリングでJavaタイプを使用することです.