I have
- A MySQL database currently in production use for a CakePHP application
- A Java SE application accessing the same database via Hibernate, currently in development.
I’m using the Netbeans “automigrate” feature to create the POJO classes and XML files (do I really need the XML files when using annotations?). As the schema is quite complex creating the tables manually is way too much work.
Cake expects all DB tables to be pluralized (the Address class is automagically mapped to the addresses table). When running the Netbeans automigration it then does pluralization on the already pluralized table names (I’m getting Addresses.java and setAddresseses() methods).
I know I’m asking for trouble running two very different data layers against the same database, but I’d like to know if it’s possible to have Netbeans generating the POJO classes in singular form or if there is another (better) way to manage this.
When doing reverse engineering, it is possible to use a custom reverse engineering strategy. Quoting the documentation:
In your case, you might want to implement
to “depluralize” classes generated from table names (
ADDRESSES=>Address).But sadly, the NetBeans Hibernate Reverse Engineering Wizard does not provide an option to pick reverse engineering strategy if the user happen to have any (this is an enhancement planned for NetBeans 7.0 if time permits).
So if you want to use a custom strategy, you’ll have to use Ant or Maven. This is currently not possible from NetBeans.