[hibernate-dev] hibernate-delta

Gregor Zeitlinger gregor.zeitlinger at txtr.com
Mon Jun 24 08:20:15 EDT 2013


The main difference is that hibernate-delta does NOT run against a live 
database.
I do load the previous version of a mapping from a custom XML file.

This enables some scenarios that are not possible with the hibernate 
build in schemaupdate, such as

 1. add a non-null column
 2. change the datatype of a column
 3. rename a column


So the workflow is as follows:

 1. Create an entity Customer
 2. Run UpdateSqlGenerator (which updates the schema.xml file)
 3. Copy the output to a liquibase or Flyway
 4. commit and push schema.xml

Note that you do not need any database connection for the entire workflow.

I do like to test it on a scratch dump from the live database when I add 
a non-null column and fill it with a qeury for example.
In addition, we have an automated test that executes changesets and 
compares the final schema with expected one from the annotations - using 
hibernate-delta - which in return uses liquibase to read the schema of 
the updated database.

Gregor


Am 24.06.2013 11:24, schrieb Max Rydahl Andersen:
> Looks interesting - what is the big difference between this and
> what the built in schemaupdate does ?
>
> If you don't look at previous versions of the mapping I would not 
> expect you to do much better (but if you do that would be the natural
> place to contribute it to)
>
> Do you got an example on how to use this ?
>
> /max
>
> On Thu, Jun 20, 2013 at 11:59:51AM +0200, Gregor Zeitlinger wrote:
>> Hi,
>>
>> I've created https://github.com/txtr/hibernate-delta because I couldn't
>> find a solution that would generate SQL update statements based on the
>> fields that I added to my @Entity.
>> The trick is that it stores the schema in an XML file that is commited
>> to git. That way, you only get the differences you introduced.
>> It can also find the differences between your XML schema and the actual
>> database (using liquibase).
>>
>> Now the questions
>>
>> 1. Is this something that already exists?
>> 2. Is somebody interested in growing this from the current setup
>>    (tested with Oracle only)?
>> 3. Would this maybe even a candidate to include in hibernate tools?
>>
>> -- 
>> Gregor Zeitlinger
>> gregor.zeitlinger at txtr.com
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev

-- 
Gregor Zeitlinger
gregor.zeitlinger at txtr.com

Notice
The information in this message is confidential and may be legally privileged.  It is intended solely for the addressee.  Access to this message by anyone else is unauthorized.  If you are not the intended recipient,  any disclosure,  copying or distribution of the message,  or any action taken by you in reliance on it,  is prohibited and may be unlawful.  If you have received this message in error,  please delete it and contact the sender immediately.  Thank you.



More information about the hibernate-dev mailing list