Is generating Hibernate Entities from database tables considered a bad practices?

  softwareengineering

On my current project it is a common practice to generate Hibernate Entities from database tables using NetBeans functionality. I’m normally used to first write the Entity-class and define the mapping in an XML-file or with annotations.

Is it considered bad practice to generate the entity classes through NetBeans (or another IDE) and are there any drawbacks to this approach?

We’re only using Hibernate 4.3 and no JPA.

1

I don’t see this as a problem, depending on your context.

In some cases you start with a database definition, perhaps you have the database from a previous project and have to adapt to it. So the database is set and your job is to provide a mapping to it. In this kind of situation you must do as you suggest.

In other cases you build something from scratch. Here it is in my opinion more a case of where the developer feels at home. Is he/she better at expressing the model through Hibernate entities or through a database definition. Then let the developer do as he/she pleases and let the other part be generated from that first artefact.

So, it may very well be a good practice in some cases.

LEAVE A COMMENT