Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Ranch Hand
Posts: 60
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
    reply
      Bookmark Topic Watch Topic
    • New Topic