Binders Lachel
Binders Lachel

Reputation: 635

Is it possible to map a normal Java bean for Hibernate in a separate class / file?

I have a normal model class

public class Person {
   private int id;
   private String name;
   ...
}

It's a model class and doesn't have any JPA / Hibernate annotations used.

Is it possible to somehow tell Hibernate to make this class persistent?

I want to use Person in queries, criteria etc, but don't want to introduce annotations to that class (it is defined in a model JAR with no JPA dependency, and I have the DB code in a different JAR);

Upvotes: 0

Views: 160

Answers (1)

Jherico
Jherico

Reputation: 29240

Hibernate supports XML mappings to map a class to a database, as well as annotations.

Upvotes: 5

Related Questions