Search Flex Components Free

Custom Search

December 17, 2007

Default generator class in Hibernate Code Generator

I am using mysql, hibernate tools and eclipse 3.2.

I am generating all my java and xml code using the wizard.

The default class generator is "assigned".. for mysql and flex data services, this doesn't work so well... we need "native"

.. one way to work around this is to create a reveng.xml file where you explicitely list each table and then add a primary_key attribute that specifies the generator class. The other way is to manually edit all the hbm.xml files after each run of the wizard. Both not great.

Instead... change the default class generator for your project.

Here's how:

Add the hibernate-tools.jar to your eclipse java project.

Create the following class in your java project (i used the default package):

import org.hibernate.cfg.reveng.*;
public class MyRevEngStrategy extends DefaultReverseEngineeringStrategy {
public String getTableIdentifierStrategyName(org.hibernate.cfg.reveng.TableIdentifier t) {return "native"; }
}

in your Hibernate Code Generator, modify the reveng.strategy.
in the popup textbox type in MyRevEngStrategy, it should find it.

Close and run. Worked for me.

Related Flex Tutorials