I am very new to Hibernate. I did my 'Hello World' with a Netbeans tutorial which showed how to generate the POJOs and mapping files from the relational tables, which seemed very logical to me!
However now when I am reading more about it, the books mention that classes are written first, then mapping files and then the DB is created. I am slightly confused. Can someone please tell me which is correct approach (I mean, how is it done in real world)
In my experience, some database admin puts together an ERD and you have to map to it. The database person has no friggin' idea how to properly design a database, and it becomes a nightmare doing the mappings. So, on most projects I've been on, that's how it's been done.
For me, I'd ideally like to create an object model, and then just have the objects map to the database. If I'm 'first in' on a project, that's what I usually do, before any database people get their dirty little hands on the project and mess everything up.
Do I sound bitter?
If you're new to Hibernate, I'd be flattered if you checked out my tutorials. Here's a little tutorial that uses the SchemaExport class to have Hibernate map an object (User class) to a database. Hibernate creates all the underlying tables for you in this example, which is really neat.