Hibernate addclass method: load entity class
•
Java
addClass(Class persistentClass)
Example
Configuration config = new Configuration(); //创建Configuration对象 Config.addClass(UserForm userForm); //加载实体类UserForm
Typical application
static{ try{ Configuration cfg = new Configuration().configure(); //加载Hibernate配置文件 cfg.addClass(Users.class); //加载实体类 System.out.println("成功的加载了实体类Users"); factory = cfg.buildSessionFactory(); //示例化SessionFactory }catch(HibernateException e){ e.printStackTrace(); } }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码