Hibernate mapping resource from external project

395 Views Asked by At

I am wondering if it is possible to map resources from an external project?

What I mean:

I have project A with hibernate.cfg.xml which will be communicating with JMS and added to buildpath project B, which has classes and HBM mappings for them.

I would like to create queries from project A, which will ask the database and return proper objects of classes defined in project B.

Any ideas how to achieve this?

A simple <mapping resource="/project/location_of_hbpm" /> in the config file doesn't work...

1

There are 1 best solutions below

0
K139 On

It is possible to map resources from external locations/projects as long as they are in CLASSPATH.

In your case, you can't because if you do, it would be a 'Circular Dependency' and it won't work.

Project B --> Depends on --> Project A (which has config/xml files). 

So you can't make

Project A --> Depend on --> Project B.

If you want to use the Project B 'POJO/Classes' in Project A, then try to extract those classes from 'Project B' into a separate JAR file and let both Project B and Project A depend on it.