can any one tell me how to force maven to precede mapping .hbm.xml files in the automatically generated hibernate.cfg.xml file with package path?
My general idea is,
how can I configure hbm2cfgxml so that hibernate.cfg.xml looks like below (...)
I have a project that is using hbm2cfgxml and the entries do reflect the packagename in the path to the hbm.xml. So there is clearly something wrong on your side. Here are a few remarks:
hbm2cfgxml on the generate-resources phase, you're not generating sourcessrc/main/resources but in target/classses (why do you put generated stuff in the source tree, you want a clean to clean it).configurationfile, not configurationFile but... in the configuration of hbm2cfgxml? You want to generate it here... I would remove it.Update: You should put the informations required to connect to the database in src/main/resources/database.properties (that's the default value of the propertyfile property), not in src/main/resources/hibernate.cfg.xml (remove that file). Below a sample database.properties:
hibernate.connection.driver_class=org.apache.derby.jdbc.ClientDriver
hibernate.connection.url=jdbc:derby://localhost:1527//home/pascal/Projects/derbyDBs/EMPLDB
hibernate.connection.username=APP
hibernate.connection.password=APP
hibernate.dialect=org.hibernate.dialect.DerbyDialect
And as I said, remove the src/main/resources/hibernate.cfg.xml file, you want to generate it.
is there a way to tell maven to copy resources to the target folder before executing hbm2java? (...)
The hbm2java goal Invokes the execution of the lifecycle phase process-resources prior to executing itself (from the documentation). So that's the default behavior and occurs with hibernate3:hbm2java or generate-sources if hbm2java is bound to it.