• 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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
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
  • 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.
     
    This tiny ad is wafer thin:
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!