Pinchy
Pinchy

Reputation: 1536

(Hibernate configuration) cannot map classes located in other project

I have got couple questions about changing hibernate configuration. There is a project say ProA has got POJO classes i.e.

Hibernate config for ProA
    <hibernate-configuration>
        <session-factory>
            <!-- Mapping files -->
            <mapping class="com.form" />
            <mapping class="com.page" />
            <mapping class="com.widget" />
        </session-factory>
    </hibernate-configuration> 

These work fine, and I also got another project say ProB and I need to use those POJO classes in that project as well. What I did was I copied the com directory to ProB and so I can fetch objects from database. However the problem is those projects are in SVN repository and when those classes are changed and committed I need to access those updated version of the pojo classes.

Is there workaround for that?

It would be so great if I could map those classes in ProB something like that?

Hibernate config for ProB
    <hibernate-configuration>
            <session-factory>
                <!-- Mapping files -->
                <mapping class="/ProB/com.form" />
                <mapping class="/ProB/com.page" />
                <mapping class="/ProB/com.widget" />
            </session-factory>
    </hibernate-configuration>

So I wouldn't need to have a copy of com directory and deal with svn syncronisation.

I would really appreciate any help.

Cheers....

Upvotes: 2

Views: 346

Answers (1)

mkro
mkro

Reputation: 1892

What you typed for ProB

<mapping class="/ProB/com.form" />

will not work. The class that you refer to has to be on the classpath. A "Folder-type" notation will not satisfy this requirement (unless you heavily hack into hibernate).

I see two issues that you have to address:

1) Make sure that you always have the latest mappings from ProB in ProA: This (I think) is an issue you can solve with an appropriate source revision control strategy, maybe by using svn externals.

2) Make sure that the mappings and classes remain compatible with how you want to use them in ProA (an organisational and test/build infrastructure issue).

I would look into how you depend on internal projects that keep changing and how you establish test/build strategies that make sure you stay compatible. If you do use something like maven and an internal repo server you could simply depend on the latest release or snapshot of ProB.

Hope that helps...

Upvotes: 1

Related Questions