IAmYourFaja
IAmYourFaja

Reputation: 56944

Alternative locations for Hibernate mapping files?

I just read an introductory tutorial on Hibernate that had all the mapping files inside the same source directory of the entities they represented:

TestProject/
    src/main/java/
        com.hibernate.tutorial.entities
            Student.java
            Student.hbm.xml

            Course.java
            Course.hbm.xml

etc. Normally, I like to place config files under src/main/config, and so ideally I'd like to have the following project directory structure:

TestProject/
    src/main/java/
        com.hibernate.tutorial.entities
            Student.java
            Course.java
    src/main/config
        hibernate/
            Student.hbm.xml
            Course.hbm.xml

Is there a way to do this, and if so, how?

Upvotes: 0

Views: 351

Answers (2)

Serhii Shevchyk
Serhii Shevchyk

Reputation: 39456

There are 2 ways to map Pojo class to hibernate entity:

  1. XML mapping
  2. Using annotations

Annotations becomes more prevalent last years. Some examples you could find here:

example1

example2

Upvotes: 1

Related Questions