views:

192

answers:

2

I'm learning hibernate and I am running into some issues. The book i'm reading is Harnessing Hibernate - Oreilly. They explain everything using ANT, but I'm not really in the moood for the hassle to write such a huge build.xml. So I'm trying to get it to work with IntelliJ.

I managed to make a mapping according to a DB table in my MySQL database, and wrote the bean for it. It worked. But I can't find anywhere on the internet how to generate beans and SQL code, or how to do reverse engineering in IntelliJ. I found loads of tutorials about eclipse, using JBOSS Hibernatetools plugin, and the site claims this support for generating code is already in the standard installation of intelliJ IDEA.

Am I forgetting some configuration, or do I forget to add libraries? I'm trying to find this out but I'm desperate now. Please don't suggest me to use Eclipse, I need IntelliJ for my job.(well I found a job to program java as a student.)

A: 

AFAIK, IntelliJ IDEA includes the complete JPA/Hibernate support in its Ultimate Edition:

Generating Persistence Mappings from Database Schema

IntelliJ IDEA allows you to quickly generate persistence mappings from any database schema: Generating Persistance Mappings

alt text

Now, the question is, what edition of Intellij IDEA are you using?

Pascal Thivent
I found that screenshot as well on jetbrains website but can't seem to find this. It only allows me to generate from database schema, not by mappings.help--> about says: intelliJ IDEA ULTIMATE 9.0 (I have a school license)
toomuchcs
A: 

If you add the hbm2ddl to your Hibernate config and ask it to create the database schema you'll get it by running a single test or some other code that exercises Hibernate. Once you have it, turn off create.

Let Hibernate do the work.

duffymo
thanks, that's already one step further, though I'm still not right on track. I added the property you said to my hibernate.cfg.xml, but now it complains it can't find the bean corresponding to the mapping file.Caused by: org.hibernate.MappingException: class com.hb.Track not found while looking for property: idthis is my cfg: http://pastebin.com/NrjFWE5p
toomuchcs