Back Forum Reply New

Howto map Hibernate from different Projects

Hi,

i do face the following problem: we have split our project into many subprojects reflecting the modularity and dependancies. two of the subprojects (lets call them P and Q) do access the database via hibernate while defining mappings for pojos and tables. the project Q depends on project P.

we do have the need of only one session factory which gets defined in one spring context file. there we have to declare all the mappings to run our junit tests for project P. because project Q depends on project P we include all the compiled classes and resources of project P to the classpath of Q (we use eclipse as ide).

but now, how to define the hibernate mappings for all mappings introduced by project Q? if we define them in the context file of project P, Q is not in the classpath and therefor the mappings defined by Q will not be found. if we define the session factory and mapping in project Q we cant run our junit tests without making P dependant on project Q (which does not reflect the reality)

is there any best practice how to define in each context file the mapping introduced by each project, using only one session factory? or which approach should be use at all?

any suggestions are welcome. thx

Couldn't you just use the PropertyPlaceholderConfigurer?  You would simply define the folder that contains the mappings as a property.  When you run the unit tests or deployment you can ensure the properties file contains the appropriate value.  For other db related stuff e.g. dialect, username, password you probably already do it so its not hard.

sp...onfigurer.html
¥
Back Forum Reply New