简体   繁体   中英

Are there maven plugins to generate java source code (entity) classes based on a hibernate entity XML?

I want to automate java source code generation through a maven java source code generator. I want to create entity classes by looking at an one big entity xml file which will have all the entities and entity relationships in a system. as far as I searched there is no such plug-in in maven for the moment.

do I have to write my own mojo to get this done?

any ideas and directions to follow will be relay appreciated.

Did you try this plugin : http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/hbm2java-mojo.html

The hbm2java goal should be what you are looking for.

If you use Eclipse or NetBeans they both have a tool to generate entity classes directly from database tables.

You would not even need to provide the XML definitions.

There are several plugins which do code generation, but it is always a custom task, eg there are plugins to generate web service classes from WSDL file, or I've used querydsl's generator for query-objects.

So, first of all, decide if you are not reinventing a wheel and there are some similar projects which do what you want. It it is not a case, take any plugin which does something similar and write your own for your situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM