aspose file tools*
The moose likes Object Relational Mapping and the fly likes Tools for Hibernate? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Tools for Hibernate?" Watch "Tools for Hibernate?" New topic
Author

Tools for Hibernate?

Priya Bindra
Ranch Hand

Joined: Sep 22, 2009
Posts: 51
Hi All,

I am designing a new J2EE application as : JSP->Struts->Hibernate->EJB3. I am thinking which tools i can use to create the hibernate side of the project. Should i hand code all the POJOs, and config files?

Also, i am a bit confused abt how to design the Hibernate layer. From Class diagrams, or from DB schema?
Sharad Jadhav
Greenhorn

Joined: Feb 10, 2010
Posts: 18
You can go for Netbeans.


Hopes that will help you.


Java J2EE Hibernate Spring
Priya Bindra
Ranch Hand

Joined: Sep 22, 2009
Posts: 51
how abt eclipse?
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 495
    
    5
Eclipse has the Hibernate Tools plugin from JBoss. It's quite good for generating artifacts. Provides all 3 approaches of using Hibernate.
But I don't prefer to use it as a starting point. My starting point is a domain model having all the entity classes, their associations and multiplicities.
I add use case specific DB fields only as association tables, when modelling use cases.
Priya Bindra
Ranch Hand

Joined: Sep 22, 2009
Posts: 51
Karthik Shiraly wrote:Eclipse has the Hibernate Tools plugin from JBoss. It's quite good for generating artifacts. Provides all 3 approaches of using Hibernate.
But I don't prefer to use it as a starting point. My starting point is a domain model having all the entity classes, their associations and multiplicities.
I add use case specific DB fields only as association tables, when modelling use cases.


Thanks Karthik. But i need more explanation.
1) what 3 approaches have you talked abt using Hibernate?
2) The starter's strategy that you have mentioned, means creating class diagrams in Unified Modelling Langualge?

As I said i am starting a new project with only the requirements by my side. It wud be great if you cud outline the series of steps i need to design and implement this project. I have created use cases broadly. What next?
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 495
    
    5
Hi,

Hibernate artifacts can be generated in 3 ways:
- top down: Start from POJO class sources. Generate mapping files and database schema from it. OR
- bottom up: Start from existing database schema. Generate POJO class sources and mapping files from it. OR
- middle out: Start from mapping files. Generate POJO sources and database schema from it.

An even higher top down approach is to generate the POJO classes themselves from a UML model (I've heard of a tool named AndroMDA but never used it).

Since you're starting from scratch, you don't have any existing database schema to constrain you. So the top down approach is best for you.

Personally, I'm comfortable with this approach below, but YMMV:
- Identify and model entity classes from the requirements and problem statements. Any passive data in the system is usually an entity class.
Am careful to not include use case specific attributes at this stage.
As a trivial example, accounts and customers are the entities in a banking app; now the app requirements may state that each customer should be able to customize the website look. So UI preferences also need to go into the DB. But that doesn't mean it's an entity - it's just use case specific information. A decade from now, the account and customer data in database is still vital for the bank, but the UI preferences will die when the website structure changes.

- So model such entities, and their associations (1-to-many, many-to-1, many-to-many, 1-1). My model is usually just a diagram, but you can try out AndroMDA or some UML tool.

- Once the entities are known, I model use cases. Sometimes, they result in attributes being added to the entities. More often, they'll throw light on what extra info needs to go into the DB.

- So now I know all the info that should be persisted - both entity relevant data as well as use case required data.

- I code the POJO classes. Some will represent the entities, some will represent use case info, and some will be association classes.
I prefer to handcode them, but you can try code generation if you're more comfortable with it.

- Then generate mapping files and database schema from them. Here Hibernate tools help. There is also middlegen standalone tool, but I haven't used it.
I usually don't prefer Hibernate annotations.

- Finally, I write unit test cases to validate that basic DB operations with these classes are ok, especially persistance of the associations.
This is my preferred way of preparing the persistence layer.


Priya Bindra
Ranch Hand

Joined: Sep 22, 2009
Posts: 51
Thanks a tonne Karthik. Great advice to a starter. I will keep asking more. Thanks again.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 495
    
    5
You're welcome!
 
 
subject: Tools for Hibernate?