• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mark Kafe
Ranch Hand
Posts: 60
Hibernate Java Oracle
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate 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

  •  
    vishwa venkat
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic