Dejell
Dejell

Reputation: 14317

exclude @Entity from persistence

I am using persistence.xml in hibernate

However, I am some @Entity in the classpath which I don't them to be part of persistence.xml.

in the documentation

class The class element specifies a fully qualified class name that you will map. By default all properly annotated classes and all hbm.xml files found inside the archive are added to the persistence unit configuration.

Is there to exclude some entities from it?

Upvotes: 2

Views: 3018

Answers (1)

Bozho
Bozho

Reputation: 597016

It's not possible afaik. But don't worry about that - if you don't use these classes they will not bother you, apart from their metadata being loaded by the session factory.

Update: hbm2ddl tools (like ant) have the excludes option. I don't know how you are using it, so search for options there.

Apart from this, you can manually list all classes in persistence.xml and use:

<exclude-unlisted-classes>true</exclude-unlisted-classes>

Upvotes: 4

Related Questions