-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: How to specify location of hibernate files?
PostPosted: Fri Jan 14, 2005 5:15 am 
Newbie

Joined: Fri Jan 14, 2005 4:58 am
Posts: 10
Hibernate version: 2.0

Sorry for this beginners question but I did not find it in the doc and the examples are all intended to be run from the hibernate install directory...

I am testing Hibernate without an app-server and simply wants to be able to run my examples from any directory on my machine (I have put my files in a JBuilder project located on another drive than were hibernate is installed and this is the "home directory" were Jbuilder execute my examples) or on a friends machine after packaging it all as JAR-files.

I have figured out what dependent JARS to use (I think!) ect but I need to specify the location of the hibernate install directory!

I would like an example of a complete command line to pass to my application in order for it to be able to use hibernate and start from any directory...

How are by the way the files in the hibernate install catalog accessed - can I include them in a JAR-file or must they be "installed" on every machine were I run my application???

I have understood the doc in the way that I can put the Java -> SQL mapping anywhere in my class path - I hope this is correct...

As you can see I have little experience with web-apps or deploying Java and hibernate but I hope somebody still is willing to take the time to answer....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 6:33 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
:hmm:
i'm not sure if i've completly understood your problem ...

Put the hibernate-config-file 'hibernate.cfg.xml' in your classpath (root) and that will work on every computer ...
Put the hibernate-mapping-files in your classpath (same location as the mapped java-classes) and that will work, too. Or put them into a directory of your choice and make it configurable ... (for the beginning, i think putting them into classpath is a better solution) ...
The last thing what have to be done is your classpath ... if you keep it relative ... everything will be perfect ...

Hope that helps a little bit ...

gtx
curio


Top
 Profile  
 
 Post subject: Ok I think I understand...
PostPosted: Fri Jan 14, 2005 6:38 am 
Newbie

Joined: Fri Jan 14, 2005 4:58 am
Posts: 10
Ok I think I understand now - I will try that...

I was looking at the hibernate/etc directory and there were a whole bunch of different config files there and I assumed that all of them needed to be located by hibernate (or its dependent products) somehow and that the way to do that should be to tell hibernate the location of the hibernate install (or etc) directory using a define on the command line or something....

Thanks a lot!

- Trist


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 6:53 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
in some special situtations you will need some more config-files ...

but for simple applications (without an app-server, second-level-cache and so on) you only need the hibernate.cfg.xml and your mapping files ...

And if you want the loggings ... you'll need the "log4j.properties" of course in your classpath.

Have fun :)
curio


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 12:46 pm 
Newbie

Joined: Wed Dec 22, 2004 11:36 am
Posts: 11
Is it possible to specify the name of the default config file on the command line? (e.g. if you want to change the config file used when running unit tests)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
When using unit tests I create the configuration programmatically.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 11:21 am 
Newbie

Joined: Wed Dec 22, 2004 11:36 am
Posts: 11
In this case, the code being tested creates the SessionFactory using the automatic configuration file finding. So the unit test doesn't have a say in how the tested code loads its configuration (unless there were a way to specify the default name of the configuration file as a property for the JVM).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 2:55 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
kokaku wrote:
In this case, the code being tested creates the SessionFactory using the automatic configuration file finding. So the unit test doesn't have a say in how the tested code loads its configuration (unless there were a way to specify the default name of the configuration file as a property for the JVM).


You might want to use the -D option on the command line. which is what I do and have the code check for it before building the sessionfactory.

_________________
Thanks
Sameet


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.