Hibernate mapping resource path in Maven

2006-10-30 Thread Andy Buckley
Hi,

I just started converting a Java project using Hibernate (www.hibernate.org) to
build with Maven rather than Ant. While I was able to get log4j logging working
again by placing my log4j.properties file in src/main/resources, and putting
hibernate.cfg.xml in the same place does result in it getting picked up by
Hibernate at runtime, I can't seem to get the mapping resource entries correct.

My directory structure is now

src/main
\ resources
|  \ hibernate.cfg.xml
|
\ java/cedar/hepdata/model
  \ Author.hbm.xml
  \ Axis.hbm.xml
  \ etc.

and in hibernate.cfg.xml, I've got mapping entries like this:

mapping resource=src/main/java/cedar/hepdata/model/Author.hbm.xml/

which result in errors like

Running cedar.hepdata.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.109 sec
Running cedar.hepdata.test.HDOMTest
Initial SessionFactory creation failed: org.hibernate.MappingNotFoundException:
resource: src/main/java/cedar/hepdata/model/Author.hbm.xml not found

I've also tried resource=/src/..., resource=../src/... and a bunch of
others (even absolute paths, which are useless from a portability point of
view) and none seem to work. Any suggestions? I suspect that the
hibernate.cfg.xml file is getting copied into the target/{,test-}classes
directories and the *.hbm.xml files aren't: should the *.hbm.xml files also be
located in src/main/resources/ to make this work?

Please help!

Andy


PS. Sorry if this is a recurring question: The only mention on the mailing list
archives that I've seen about getting Hibernate working was using mappings like
mapping class=cedar.hepdata.model.Author /
but these seem to require Hibernate Annotations and I'm not (yet) using them.
The Hibernate doc/FAQ pages aren't much help either, since they only seem to be
referring to Maven 1.x.

-- 
Andy Buckley: CEDAR @ IPPP, Durham
Work: www.cedar.ac.uk
www.insectnation.org

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Hibernate mapping resource path in Maven

2006-10-30 Thread Marco Mistroni

Hello,
 yes you should make sure that your hibernate files end up in the resources
directory of your src/java

after that there isno need to put absolute path for your classes, you can
just puit

cedar/hepdata/Author.hbm.xml

and that should work..

hth
marco


On 10/30/06, Andy Buckley [EMAIL PROTECTED] wrote:


Hi,

I just started converting a Java project using Hibernate (
www.hibernate.org) to
build with Maven rather than Ant. While I was able to get log4j logging
working
again by placing my log4j.properties file in src/main/resources, and
putting
hibernate.cfg.xml in the same place does result in it getting picked up by
Hibernate at runtime, I can't seem to get the mapping resource entries
correct.

My directory structure is now

src/main
\ resources
|  \ hibernate.cfg.xml
|
\ java/cedar/hepdata/model
  \ Author.hbm.xml
  \ Axis.hbm.xml
  \ etc.

and in hibernate.cfg.xml, I've got mapping entries like this:

mapping resource=src/main/java/cedar/hepdata/model/Author.hbm.xml/

which result in errors like

Running cedar.hepdata.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.109 sec
Running cedar.hepdata.test.HDOMTest
Initial SessionFactory creation failed:
org.hibernate.MappingNotFoundException:
resource: src/main/java/cedar/hepdata/model/Author.hbm.xml not found

I've also tried resource=/src/..., resource=../src/... and a bunch of
others (even absolute paths, which are useless from a portability point of
view) and none seem to work. Any suggestions? I suspect that the
hibernate.cfg.xml file is getting copied into the target/{,test-}classes
directories and the *.hbm.xml files aren't: should the *.hbm.xml files
also be
located in src/main/resources/ to make this work?

Please help!

Andy


PS. Sorry if this is a recurring question: The only mention on the mailing
list
archives that I've seen about getting Hibernate working was using mappings
like
mapping class=cedar.hepdata.model.Author /
but these seem to require Hibernate Annotations and I'm not (yet) using
them.
The Hibernate doc/FAQ pages aren't much help either, since they only seem
to be
referring to Maven 1.x.

--
Andy Buckley: CEDAR @ IPPP, Durham
Work: www.cedar.ac.uk
www.insectnation.org

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Hibernate mapping resource path in Maven

2006-10-30 Thread Aleksei Valikov

Hi.


I just started converting a Java project using Hibernate (www.hibernate.org) to
build with Maven rather than Ant. While I was able to get log4j logging working
again by placing my log4j.properties file in src/main/resources, and putting
hibernate.cfg.xml in the same place does result in it getting picked up by
Hibernate at runtime, I can't seem to get the mapping resource entries correct.

My directory structure is now

src/main
\ resources
|  \ hibernate.cfg.xml
|
\ java/cedar/hepdata/model
  \ Author.hbm.xml
  \ Axis.hbm.xml
  \ etc.


1. Put your HBM files into resources, not into java. You should have 
src/main/resource/cedar/hepdata/mode/Autor.hbm.xml etc.


2. Use

mapping resource=cedar/hepdata/model/Author.hbm.xml/

Bye.
/lexi

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Hibernate mapping resource path in Maven

2006-10-30 Thread Andy Buckley
Aleksei Valikov wrote:

 1. Put your HBM files into resources, not into java. You should have
 src/main/resource/cedar/hepdata/mode/Autor.hbm.xml etc.
 
 2. Use
 
 mapping resource=cedar/hepdata/model/Author.hbm.xml/

Fantastic, thanks. The whole tree seems not to be needed, so just making e.g.
src/main/resource/hbm/Author.hbm.xml and pointing the config file at those
seems to work nicely, without having a chain of empty directories for no
particular reason.

Thank you!
Andy

-- 
Andy Buckley: CEDAR @ IPPP, Durham
Work: www.cedar.ac.uk
www.insectnation.org

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]