Hibernate - How to control generator class used when running hbm2hbmxml
My hbm2hbmxml task is generating ids such as below
<id name="id" type="long">
<column name="id" />
<generator class="assigned" />
</id>
I'd like them all to be "native". Can I confi开发者_Python百科gure the Hibernate reverse engineering to do this?
Thx, Fred
Yes. You can create a custom ReverseEngineeringStrategy by extending DelegatingReverseEngineeringStrategy, override
@Override public String getTableIdentifierStrategyName(final TableIdentifier tableIdentifier) {
// Always use native identifier strategy
return "native"; }
and have HibernateToolTask refer to this class: reversestrategy="com.foo.MyReverseEngineeringStrategy"
Cheers, Kjeld
精彩评论