• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

hibernate-configuration-file property set from out side cfg.xml file

Ranch Hand
Posts: 60
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i want to hibernate-configuration-file property for examples

i want to not hard code in configuration file i put it any text files where any user easily change according theirs database, user name and password
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see how being in a text file rather than an xml file, which is also a text file, is any easier to change. Arguably having more than one place your SessionFactory is configured may make the applciation less easy to configure? But that is not to say you can't do it. There are a number of ways of doing this:
  • Have a look at the Configuration class. It has a number of ways of specifying where the configuration file is and what its called.
  • You can also configure the SessionFactory using a properties file (by default hibernate.properties will be used if it is on the classpath). One weakness this has over an XML file is you no longer have the extra validation XML can provide against a schema or DTD
  • You can supply extra properties as system properties, so this could be a parameter entered when running your application
  • You can do all this programatically, so can use any other mechanism you can dream up if you are willing to take the time to code it

    Ranch Hand
    Posts: 185
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    look for ant filter config for hibernate config. by which you can pass the parameters to hibernate config from ant build target.
    Anderson gave himself the promotion. So I gave myself this tiny ad:
    Thread Boost feature
      Bookmark Topic Watch Topic
    • New Topic