In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the example analysis of the Hibernate configuration file, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
There are two Hibernate configuration file formats, one is XML, the default is Hibernate.cfg.xml, and the other is properties, which defaults to Hibernate.properties different configuration files, and the initialization method for Hibernate is different.
For example, if you use the properties file as the Hibernate configuration file
Then the initialization code is roughly as follows
Configuration config = new Configuration (); config.addClass (myclass.class)
If the Hibernate profile is XML,
Configuration config = new Configuration () .config ()
Configuration files in XML file format do not support the addClass method! This is because the Mpaaing file is already defined in the Hibernate configuration file XML file, so there is no need to import the POJO file in a coded manner.
Another: many articles on the Internet, and even some books, say that the configuration file of Hibernate must be placed in the root directory of class. Refer to API and find that this statement is incorrect, such as Configuration config = new Configuration (). Config (configuration file name); that's fine.
All config methods are as follows:
AddCacheableFile (File xmlFile) If a cached xmlFile + ".bin"
Exists and is newer than xmlFile the ".bin" file will be read directly.
Configuration addClass (Class persistentClass)
Read a mapping from an application resource, using a convention.
Configuration addDirectory (File dir)
Read all mapping documents from a directory tree.
Configuration addDocument (org.w3c.dom.Document doc)
Read mappings from a DOM Document
Configuration addFile (File xmlFile) Read mappings from a particular XML file
Configuration addFile (String xmlFile) Read mappings from a particular XML file
Void addFilterDefinition (FilterDefinition definition)
Configuration addInputStream (InputStream xmlInputStream)
Read mappings from an InputStream
Configuration addJar (File jar) Read all mappings from a jar file
Configuration addProperties (Properties extraProperties) Set the given properties
Configuration addResource (String path)
Read mappings from an application resource trying different classloaders.
Configuration addResource (String path, ClassLoader classLoader)
Read mappings from an application resource
Configuration addURL (URL url) Read mappings from a URL
Configuration addXML (String xml) Read mappings from a String
The above is all the content of the article "sample Analysis of Hibernate configuration File". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.