开发者

Metamodel classes generated by Hibernate tools

I'm using Hibernate Tools in Eclipse to reverse engineer the domain entities of an existing database.

I more-or-less have everything generating how I want, although I still get a batch of "Metamodel" classes generated alongside my domain classes. These are classes with the same name, but suffixed with and underscore "_".

I've read some docs on the me开发者_JAVA技巧tamodel concept here, but I'm still not sure on their purpose...

Is it safe for me to simply delete those classes? If they are not useful to me I'd rather not have them cluttering up my package explorer.


The Metamodel classes are used by the "typesafe Criteria API" that was added in JPA 2.0. Details on this API are here:

http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html_single/#querycriteria

Hibernate EntityManager can use the metamodel classes to verify that a Criteria is valid for a given set of entities. For example, if you attempt to write a query which adds a "where" clause against an entity's property, Hibernate can validate the property actually exists in your model and (I believe) generate a compile-time error or warning. With Hibernate's old Criteria API, the only way to validate such a query was to execute it and see if an exception was thrown.

If you don't plan to use this Criteria API then it's probably safe to delete the classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜