A null in the database cannot be assigned to an int, and the failure happens at load time.
@Entity
class Order {
int quantity; // column is nullable -> exception on load
Integer discount; // correct for a nullable column
}
org.hibernate.PropertyAccessException:
Could not set field value [null] value by reflection : [Order.quantity]
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11