Hibernate is the best ORM in Java. It provides a wrapper in .NET also as NHiberate. But it can be tough when you have alot of entities to create manually and create a reference between them. The most comprehensive task is to manually develop the relationship between them. Yes there is database-approach also which generates all the things from the database, We are currently supposing model first approach and then connect database with it.

Eclipse provides many tools to generate the simple POJO classes by a simple visualizer. Texo is one of the good plugin in Eclipse that generate entities from EMF ecore models. When you connect the texo generated entities with hibernate via mapping in XML files. It pop out an error that

Failed to create sessionFactory object.java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set

Because the Texo genenates entities with LIST type and hibernate gives an error. We can to generate all the Collection objects as a SET in order to solve the problem.

To resolve the problem we have to generate the ORM ANNOTATED MODEL and set all the collection attributes "use list" property to false

Generate the Texo Hibernate

Selecting the collection object

Create new Gen Annotation for object

set use list = false