What should receive method (EntityModel) template.get("EntityModel", id) ? In my case, id is just primaryKey, and EntityModel is the name of the table.

  @Transactional(readOnly = true) public EntityModel getEntMod(Long id){ EntityModel entityModel = (EntityModel) template.get("EntityModel", id); return entityModel; } 

    1 answer 1

    If you open the Javadoc by HibernateTemplate, then there it is directly written:

     public Object get(String entityName, Serializable id) throws DataAccessException 

    If you’re not found. This method is a thin wrapper around Session.get (String, java.io.Serializable) for convenience. For an explanation of this method, please do refer to the Hibernate API documentation in the first instance.

    Parameters:

    entityName - the name of the persistent entity

    id - the identifier of the persistent instance

    If you do not specify the name parameter in the / XML annotation, then entityName is the same as the name of your class.

     @Entity(name="MyEntityName") 

    I would advise you to leave HibernateTemplate - no one really uses it. And use Hibernate directly. Examples of such online will be much more.