zoukankan      html  css  js  c++  java
  • load和get

    参考:hibernate延迟加载(get和load的区别)

    Hibernate之load和get的区别

    get方法的doc解释:

        /**
         * Return the persistent instance of the given entity class with the given identifier,
         * or null if there is no such persistent instance. (If the instance is already associated
         * with the session, return that instance. This method never returns an uninitialized instance.)
         *
         * @param entityType The entity type
         * @param id an identifier
         *
         * @return a persistent instance or null
         */
        <T> T get(Class<T> entityType, Serializable id);

    load方法的doc解释:

        /**
         * Return the persistent instance of the given entity class with the given identifier,
         * assuming that the instance exists. This method might return a proxied instance that
         * is initialized on-demand, when a non-identifier method is accessed.
         * You should not use this method to determine if an instance exists (use get()
         * instead). Use this only to retrieve an instance that you assume exists, where non-existence
         * would be an actual error.
         *
         * @param theClass a persistent class
         * @param id a valid identifier of an existing persistent instance of the class
         *
         * @return the persistent instance or proxy
         */
        <T> T load(Class<T> theClass, Serializable id);
  • 相关阅读:
    Magento 安装时文件权限 设置
    进度十(10.28)
    进度九(10.27)
    进度八(10.26)
    进度六(10.24)
    进度五(10.23)
    进度四(10.22)
    进度三(10.21)
    进度二(10.20)
    进度一(10.19)
  • 原文地址:https://www.cnblogs.com/drizzlewithwind/p/6159747.html
Copyright © 2011-2022 走看看