Data recorded in the table clearly there, session.get (class .class, id); return null

 

 

 

Null roadmap appear first checks the database whether it is really the record

Does exist, use the interface to check the maximum, also exist, normal database connection

Write sql can also get this

 

However strange thing happened

Could it have been dao of a problem with the code?

   public Article getById(Session session, int id) {
        return (Article) session.get(Article.class, id);
    }

 

Id for a try ,,, die ah, the code no problem ah

 There is no way, when I was writing the query hql

When, at last, a useful error message

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.hs.model.SectionModel#0]

 

Ah sectionId the original foreign key references the table there is no record section

Open Table, a look that was not

id is a minimum of 1

The record changed a bit

problem solved

 

 But that is no way to solve my business problems, to be continued

 

Guess you like

Origin www.cnblogs.com/jnhs/p/11401316.html
Recommended