Does IntelliJ IDEA support Hibernate Code auto-generation?
Hi guys,
I am currently using IntelliJ IDEA 9.0.4.
In the past, I have used Eclipse, MyEclipse, NetBeans and a few command-line tools such as the one that comes with JBoss Seam. All these IDEs / Tools allowed me to point them to a database, select database objects (apart from JBoss Seam command-line utility which does this for entire database schema) and auto-generate Java code, .hbm files, hibernate.cfg.xml file and even some test code.
I don't seem to be able to do that using IDEA. The Hibernate plugin that I managed to download for IDEA seems pretty lame. It just allows me to run HQL. But to run HQL, I first need to create entities.
Am I missing something?
I am looking to use Hibernate 3.6.4.
I look forward to hearing from you.
Best Regards,
Ashish.
Please sign in to leave a comment.
You're missing something. Assuming you're using the Ultimate Edition you don't need any extra plugins. In your defense, it's pretty obtuse how to find and use it.
First you need to define a data source and load the schema from the database. Then, in the project structure settings, associate a session factory with the data source in the Hibernate facet.
Once you've done that, the Persistence window lists the session factory. Right-clicking on it gives you the option to generate persistence objects from the database schema. You can also open a HQL window to test queries.
Hi Charles,
Yes, I am on Ultimate Edition.
I will give that a go and will post the result back here.
Thanks for your response.
Best Regards,
Ashish.
Hi Charles,
I have carried out the actions you have mentioned and have successfully managed to create the Entities.
Thanks for your help.
Best regards,
Ashish.
Hi Charles,
I think you're missing something too. :)
Even version 12 of IDEA doesn't support simple creation of Hibernate DAO objects like other IDEs do as part of their reverse engineering process. Sure, reverse engineering the Entity objects is good, as you noted in your posting, but that's really just the starting point.
While IDEA is an awesome, and very smart, IDE with many powerful features, I find it lacking in boilerplate code generation to help me be as productive as possible in the environments I've been in. For me, this one missing feature is a deal breaker.
As an example, if you have, say, a couple hundred tables with 1:M and more complex relationships, IDEA seems to want you to code all those DAOs yourself!!!
Since this is just boilerplate code and other IDEs do this generation for you, why doesn't IDEA? There is nothing magical, cool, or noteworthy about DAO objects -- They're just boilerplate code that without generation assistance, will take a lot of time.
I noticed as the original poster of this thread did too that the Hibernate Tools aren't apparently supported by IDEA and was last updated in 2006 (over six years ago).
Unfortunately, I've never been able to find a (plug-in, or other) workaround for this expectation (by IDEA) that I need to manually create potentially hundreds of DAOs. We just don't have time for that on our projects (especially, when other IDEs do automate this boilerplate coding for you).
We need to concentrate on business logic, not spending many hours or days creating boilerplate code that, IMHO, the IDE should be doing.
I have liked IDEA a lot since I first started using it, but now sadly just use it for small stuff.
Hopefully JetBrains will implement more boilerplate code generation soon. IDEA will be a much better IDE for adding more boilerplate code generation.
- m
Absolutely, Eclipse has a nice tool to pick various settings to do the config file for hibernate for instance - very helpful... spent 1 hr trying to figure out which is the right way to do this config file for the "persistence" dialog (which by the way is pretty shabby from options and support tooling)
..but what about IntelliJ Community Edition? can we also perform the .hbm files generation? or generally - how would I perform reverse engineering for Hibernate?
Community edition does not provide Java EE integration including Hibernate support, see Comparison matrix.
About Java class entities generation from database please check Generating managed entity classes and O/R mappings.