Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate and eclipse

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm posting here because i hope someone using hibernate AND eclipse can help me

my problem: using eclipse 3.1 (beta) and hibernate, i place hibernate.cfg.xml along with log4j.properties inside bin directory

all works fine till i have to change something at project properties: from this moment on, eclipse simply deletes those two files!

how can i assure they stay there forever?
how can i add them to classpath permanently?

TiA
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say you add them to the bin directory, what exactly are you refering to?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my workspace has a root folder and inside has a src and a bin (for class files) directories. I guess bin is (for eclipse) the root of classpath; anyway is there where hibernate finds log4j.properties and hibernate.cfg.xml
[ July 04, 2005: Message edited by: miguel lisboa ]
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting it in your src folder. That's where I put those files for my projects (actually, I use Maven, but I still put them in the source folders rather than the build folders that contain compiled .class files).

Todd Farmer
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your idea

that really works: i guess when eclipse makes a full rebuild deletes everything under 'bin' - so there go away my files

but under 'src' nothing is touched: very cool

 
Jack Wiesenthaler
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
eclipse deletes everything under the output folder. I usually just have an ant task that synchs any config files with the output after full compilation.

BTW, it is usually called classes not bin, that is not the standard per the J2EE webapp spec.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kevin Arouza:

BTW, it is usually called classes not bin, that is not the standard per the J2EE webapp spec.


Why do you assume it's a webapps?
 
Dave Turkel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends what you are doing.

I usually set my project's output directory to "internal-build" so I know exactly what Eclipse has built. I do keep a bin directory for scripts and such. Config files I'll put under "src" or make a folder called "config".

If I need the config file to run something, I'll include it in the "run" task's classpath. This keeps things clean for an Ant build (I haven't used Maven).

This is also useful for architecting multiple config sub-directories based on environmental concerns (test/staging/dev databases etc.)
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my app is a home made one
anyway i got curious aboutcreating folders to have all those .hbm in one place

now i've a prob: how to tell hibernate all my .hbm now are at /config?

TiA
 
Dave Turkel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you can just add that path to your project's classpath. I have a main hibernate.cfg.xml, with separate *.hbm.xml files for each "hibernated" class.

My hibernate.cfg.xml references each of the .hbm.xml files. I'm not sure if it assumes items are in the same directory, or will use the Classloader to find them.

When you create a build, you'll need to make sure that either the mapping files are in the root of one of your JAR files, or that they are placed in a directory that your application server can see. There are other ways of packaging as well, but these two seem to be the simplest in my limited experience.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic