Meaningless Drivel is fun!*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Refactoring Databases: Do you present frameworks for schema evolution in the book? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Refactoring Databases: Do you present frameworks for schema evolution in the book?" Watch "Refactoring Databases: Do you present frameworks for schema evolution in the book?" New topic
Author

Refactoring Databases: Do you present frameworks for schema evolution in the book?

Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Scott and Pramod,

Aren't ORM (Object Relational Mapping) tools the right tools for doing schema evolution? What comes in my mind is Hibernate's SchemaUpdate tool.

Do you take already existing frameworks into account in your book? Or do you say one has to do schema evolution from scratch

Regards,
Darya


SCJP, SCJD, SCWCD, SCBCD
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I believe they did consider all the tools available related to refactoring.

Couldn't get you by "schema evolution from the scratch". Its gonna be evolve and you have to consider it. From the scratch is not a likely solution. Refactoring goes more like a little change in each transformation. Its like

"If you have better today doesn't mean you had bad yesterday"

Cant remember the exact one . Scott, could you please help me in this?
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
With Schema evolution from scratch I mean, that I don't use an existing tool like Hibernate and care myself for having a consistent schema.

Honestly, I would leave it to the tool suppliers, because they know better than I on how to tackle the schema evolution problem.

So why inventing the wheel

Regards,
Darya
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Darya Akbari:
Honestly, I would leave it to the tool suppliers, because they know better than I on how to tackle the schema evolution problem.


But is that actually true? You are assuming that the data-model can be derived from the object model - but as both serve different purposes both models have to be able to evolve independently and the changes need a decision-making human as a driver.

Agile Data: Why Data Models Shouldn't Drive Object Models (And Vice Versa)
Agile Data: Mapping Objects to Relational Databases: O/R Mapping In Detail
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Peer,

I hope that it's true . Otherwise Hibernate would have a problem. But as far as I know Hibernate is very well established in world's J2EE community.

Regards,
Darya
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
SchemaUpdate is simply a tool that comes with Hibernate. I suspect that its contribution to Hibernate's overall success (or demise) is relatively minor, People aren't going to stop using Hibernate because of what SchemaUpdate can't do, while other people are still going to start using Hibernate even if SchemaUpdate doesn't work for them.

J2EE Schema Management with Hibernate

The tool net.sf.hibernate.tool.hbm2ddl.SchemaUpdate allows an application to bring a schema up to date with the expected schema based on a set of *.hbm.xml files. Typically, this is used to address a situation in which an incremental update to an application requires a relatively minor change, such as a new property.


Tools often only automate simple tasks, which is good for tasks that are repetitive and/or tedious. Tools like refactoring browsers even help the competent developer accomplish refactoring tasks much more quickly. But fully automated refactoring? I don't think so.
Scott Ambler
author
Ranch Hand

Joined: Dec 12, 2003
Posts: 608
Couple of things:
1. I don't remember the exact quote, or where it's from. Sorry.
2. We present full code in the book for implementing the refactorings. One to show how simple it is to implement them (hence removing the excuse that there isn't any tools) and two because the tools aren't there yet (although they're coming).
3. Although Hibernate is a popular tool, it really isn't all that sophisticated (which might be why it's so popular). It's helped to make O/R mapping popular in the J2EE community, but when you start getting involved with more complex projects that go beyond the "a class maps to a table" idea you find that you need something a little more robust. Perhaps Hibernate will evolve, or perhaps it'll remained focused on the current niche that it fills. Time will tell. My advice is to expand your horizons a bit and understand the true nature of O/R mapping, and O/R issues in general (www.agiledata.org will go a long way towards this goal).

- Scott


<a href="http://www-306.ibm.com/software/rational/bios/ambler.html" target="_blank" rel="nofollow">Scott W. Ambler</a><br />Practice Leader Agile Development, IBM Rational<br /> <br />Now available: <a href="http://www.ambysoft.com/books/refactoringDatabases.html" target="_blank" rel="nofollow">Refactoring Databases: Evolutionary Database Design</a>
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Scott Ambler:
It's helped to make O/R mapping popular in the J2EE community, but when you start getting involved with more complex projects that go beyond the "a class maps to a table" idea you find that you need something a little more robust.


Indeed. The Vietnam of Computer Science
[ July 27, 2006: Message edited by: Adeel Ansari ]
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
If it's really that simple to implement and tackle the schema evolution problem why do most people (at least the ones I know ) use a ORM tool

There are some big points that comes into my mind, why I prefer the tool:

  • increased performance
  • increased productivity
  • improved portability

  • Now aren't these reasons enough .

    I agree with Scott that knowing more about the issue doesn't hurt :roll: , but to make a conclusion from it that today's tool suppliers aren't better than I (and most of us) in achieving above goals is, in my mind, a step in the wrong direction.

    An ORM framework gives you all that for free. So, why on earth should I do it myself .

    Regards,
    Darya
    [ July 27, 2006: Message edited by: Darya Akbari ]
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    Darya, I have the vague feeling that when you talk about schema evolution you mean something different than Scott.


    The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
    Peer Reynders
    Bartender

    Joined: Aug 19, 2005
    Posts: 2922
        
        5
    Originally posted by Darya Akbari:
    ... why do most people (at least the ones I know ) use a ORM tool


    Most people use an object relational mapping tool to relieve them of the burden of having to write pages and pages of code to deal with the Object Relational Impedance Mismatch - i.e. a DAO a for every little object or aggregate (I'm fully aware that there are DAOs on top of Hibernate in some of the source samples - however those are empty shells compared what you would have to write in the absence of an ORM layer). With an ORM tool you simply provide the relational to object mapping information via configuration and it does the rest. In more complicated scenarios you will have to supply hand-coded adaptors that the ORM layer can use but even that code is minimal compared to an entirely hand-coded solution.

    Hibernate also helps you along with transaction support, including their support of what they call "Application Transactions", managed versioning, detached objects, etc. Hibernate still has some growing to do when it comes to Stored Procedure support. Currently it only supports a limited number of variations for stored function signatures which can make it difficult to integrate it with an existing "stored procedure" layer - stored procedures can be quite a powerful tool for hiding the actual data model from the layers above it (separation of concerns) and competently written stored procedures (which run on the DB server) can be quite a bit more efficient than any code run in an ORM layer or in the application code. This added layer of indirection can also make it easier to refactor the database independently of anything above the stored procedure layer.

    Gavin King is quite adamant in "Hibernate In Action" that Hibernate does not free you from the burden of mastering SQL or becoming competent in Data-modeling techniques and your RDBMS in general. The book also talks at length about object-relational-mapping in general to establish the motivation for creating Hibernate in the first place.

    Using an ORM tool actual makes some concessions in performance - but in many cases the performance loss is minimal compared to what you gain. So the core motivations for ORM have nothing to do with "updating" or "evolving" a database schema. Hibernate just happened to provide a tool that would quickly update the database schema based on your object mappings. And the modifications that it generates may very well be quite different to the schema modifications that an experienced data-modeler/DBA may make to accommodate the changing persistence needs of applications and the enterprise as a whole.

    BTW: the only reference to tools that I saw, was in Pramod Sadalage's article Evolutionary Database Design. The tools referred to are scripts for common database tasks that you write (and test) yourself.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Refactoring Databases: Do you present frameworks for schema evolution in the book?
     
    Similar Threads
    Refactoring Databases: Schema Evolution and Maintaining Data
    C++ XML by Fabio Arciniegas
    How to automate insert statement using hibernate config file
    Art of Java: how and what frameworks are covered?
    Q. To Mr.Neal Ford from a beginner