javax.persistence.EntityNotFoundException : unable to find error

Javax.mail. Persistence. EntityNotFoundException: Unable to find a class with id?
The reason:
Whether @OneToone or @ManyToone, this is due to the fact that the child table (associated table) has no records corresponding to the ID in the primary table (associated table).
Solutions:

    to check why there is no record for ID in the primary table if the data can be loaded normally without a record for ID in the primary table, you need to add an @notfound Annotation to the primary table field. Example: @onetoone (optional=true)
    @joincolumn (name=”UserId “,insertable=false, updatable=false)
    @notfound (action=NotFoundAction.IGNORE)
    private UserId UserId; In this way, when no data is found in the child table, the corresponding field in the main table is null and no error is reported. Or contact the business personnel, see the data simulation problem, directly kill (I am directly killed)


Read More: