hibernate一些概念的理解(未完待续)

xiaoxiao2024-03-28  50

[size=large]hibernate.hbm2ddl.auto = create. Usually you only leave it turned on in continuous unit testing, but another run of hbm2ddl would drop everything you have stored - the create configuration setting actually translates into "drop all tables from the schema, then re-create all tables, when the SessionFactory is build". 可以看到它是删除再重建,我以前理解的是没有则重建,有则清空,看来是不对的。 [/size] [size=large] We recommend you declare consistently-named identifier properties on persistent classes. We further recommend that you use a nullable (ie. non-primitive) type. 为什么推荐我们不要设置基本类型那?不懂。。。。。。看来还需要高手的解释,特别是读过源码的人。。。。。。。。 [/size] [size=large] Properties need not be declared public - Hibernate can persist a property with a default, protected or private get / set pair. 这个得益于java提供强大的反射功能。 [/size] [size=x-large] Hibernate will always look for the DTD in its classpath first. If you experience lookups of the DTD using an Internet connection, check your DTD declaration against the contents of your claspath. [/size] [size=x-large]我当时还比较担心,他会不会到网上去查找DTD文件,因为本地都有了,现在看来我是彻底错了。[/size] [size=large]It is perfectly acceptable for the named persistent class to be an interface. You would then declare implementing classes of that interface using the <subclass> element. You may persist any static inner class. [/size] [size=large]我们经常提到hibernate提供了很好的POJO映射支持,当时我还因为它只支持POJO,现在看来我错了,但是如果因为接口和内部静态类的话,可能又增加了复杂性。[/size] [size=x-large]The access attribute lets you control how Hibernate will access the property at runtime. By default, Hibernate will call the property get/set pair. If you specify access="field", Hibernate will bypass the get/set pair and access the field directly, using reflection.[/size] [size=x-large]如果我们设置了access="field",那么hibernate的直接使用反射来访问这个属性,个人感觉反射破坏了封装,但作为工具的话这么做还可以。[/size]
转载请注明原文地址: https://www.6miu.com/read-5014586.html

最新回复(0)