假设我有一个包含200列的表,其中大多数从未使用过.
我将SmallEntity映射到经常使用的10列.我在与其他实体的关联中使用它.它加载速度快,消耗少量内存并让我开心.
但有时我需要显示200列.我想在200列上映射BigEntity类.它没有其他实体,它没有任何关联.
问题:你有这方面的经验吗?您是否意识到Hibernate会遇到任何问题,例如在一级缓存,脏检查和实体生命周期中?
我有一个使用SchemaUpdate的主方法在控制台上显示要更改/创建的表,它在我的Hibernate项目中工作正常:
public static void main(String[] args) throws IOException {
//first we prepare the configuration
Properties hibProps = new Properties();
hibProps.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("jbbconfigs.properties"));
Configuration cfg = new AnnotationConfiguration();
cfg.configure("/hibernate.cfg.xml").addProperties(hibProps);
//We create the SchemaUpdate thanks to the configs
SchemaUpdate schemaUpdate = new SchemaUpdate(cfg);
//The update is executed in script mode only
schemaUpdate.execute(true, false);
...
Run Code Online (Sandbox Code Playgroud)
我想在JPA项目中重用此代码,没有hibernate.cfg.xml文件(也没有.properties文件),而是一个persistence.xml文件(在JPA规范中指定的META-INF目录中自动检测) .
我尝试过这么简单的改编,
Configuration cfg = new AnnotationConfiguration();
cfg.configure();
Run Code Online (Sandbox Code Playgroud)
但是那个例外失败了.
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found
Run Code Online (Sandbox Code Playgroud)
有人这样做过吗?谢谢.
我是Visual Studio 2010和VisualSVN的新手.我已经找到了如何共享项目(实际上是一个解决方案):右键单击解决方案> VisualSVN>向Subversion添加解决方案.它工作正常.现在我很遗憾,我想从SVN解开这个解决方案,并继续在我的项目上独立工作.我怎么做?
非常感谢你们.