I am considering using Hibernate for a project, but I need to know something about its capabilities.
If you use java objects to create a schema, how smart is the schema update?
e.g if I change the name of a field in an object, will the table column name change? Or will the old column get dropped and a new unpopulated column be created?
Assuming annotations are used.
First off never use schema generation/update in production, that was never its intent. It is a development tool only. That said you can set the column name and the field names can be changed without affecting the column.
I can rename myField to whatever I want and the column name will remain the same.
I guess there are people from different camps on this. Personally I believe that one of the major advantages of using an ORM is the ability to focus on the Domain (object) relationships and not have to have those objects reflective of the relational (database) model. Therefore I typically start with creating my objects in a way that makes sense for my application. I can basically ignore the database at this stage. When I have that set up I put the relationships in and then if this is a new database, generate the schema and make tweaks as necessary.
For example if I have a person object and the person object contains an Address object I do not need to worry about whether the address details live in the same table as the other person properties or in its own 'ADDRESS' table. I can account for that with my mappings later. Also often times the database already exists. In this case the trick is usually mapping the existing relational model to my domain model. Not the other way around or you lose one of the biggest advantages of an ORM imo.