Org. hibernate. propertyaccessexception: null value was assigned to a property of primitive type Sette

Source: Internet
Author: User

This exception means that the int type cannot be assigned null, while the integer type can.

If the int value can be null in the MySQL database, the integer type should be used in my modle class and ing file.

This is not the same as the automatic unpacking of Java 5.

 
Integer I = 3; // auto-boxing int A = I + 3; // auto-Unpacking

Note the NULL pointer exception (nullpointerexception) When unpacking )!

For example, integer x = NULL;
Int y = X;

Solution:

Set the original

<Property name = "cookie_id" type = "int"> <column name = "cookie_id"/> </property>

Change

 
<Property name = "cookie_id" type = "Java. Lang. Integer"> <column name = "cookie_id"/> </property>

The modle class should also be changed:

 
Private integer cookie_id;

Org. hibernate. propertyaccessexception: null value was assigned to a property of primitive type setter of modle. member. cookie_idorg.hibernate.property.basicpropertyaccessor $ basicsetter. set (basicpropertyaccessor. java: 109) Org. hibernate. tuple. entity. abstractentitytuplizer. setpropertyvalues (abstractentitytuplizer. java: 352) Org. hibernate. tuple. entity. pojoentitytuplizer. setpropertyvalues (pojoentitytuplizer. java: 232) Org. hibernate. persister. entity. abstractentitypersister. setpropertyvalues (abstractentitypersister. java: 3580) Org. hibernate. engine. twophaseload. initializeentity (twophaseload. java: 152) Org. hibernate. loader. loader. initializeentitiesandcollections (loader. java: 877) Org. hibernate. loader. loader. doquery (loader. java: 752) Org. hibernate. loader. loader. doqueryandinitializenonlazycollections (loader. java: 259) Org. hibernate. loader. loader. dolist (loader. java: 2232) Org. hibernate. loader. loader. listignorequerycache (loader. java: 2129) Org. hibernate. loader. loader. list (loader. java: 2124) Org. hibernate. loader. hql. queryloader. list (queryloader. java: 401) Org. hibernate. hql. ast. querytranslatorimpl. list (querytranslatorimpl. java: 363) Org. hibernate. engine. query. hqlqueryplan. performlist (hqlqueryplan. java: 196) Org. hibernate. impl. sessionimpl. list (sessionimpl. java: 1149)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.