Results 1 to 10 of 26

Thread: hibernate.hbm2ddl.auto consult and doubts

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Question hibernate.hbm2ddl.auto consult and doubts

    Hello guys

    Code:
    <property name="hibernateProperties">
    	<props>
           	<!-- SQL dialect -->
    	<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
     	            
    	<!-- Enable Hibernate's automatic session context management -->
    	<prop key="hibernate.current_session_context_class" >thread</prop>
    	<!-- Disable the second-level cache  -->
            <prop key="hibernate.cache.provider_class" >org.hibernate.cache.NoCacheProvider</prop>
            <!-- Echo all executed SQL to stdout -->
    	<prop key="hibernate.show_sql" >true</prop>			
    					
    	<!-- Drop and re-create the database schema on startup -->
     	<prop key="hibernate.hbm2ddl.auto" >create</prop> 
    	</props>
    </property>
    i see that each time that i startup my tomcat,
    well the db is created each time and all db data is losted

    so to avoid this,
    to before to shutdown and startup again,
    well i comment the bold line and all the db is keep it with the data

    but i am lost with this
    if i instead of create value i use
    update

    well

    1:what happens if now in my hbm files i create for the old tables more fields?
    2: i create new tables
    3: for these new tables maybe can now has relations to the old tables

    so for the old tables
    which behaviour would has this update in the schema?,
    specially with the old rows already inserted in the db?

    i am lost with this

    some advice of answers are really appreciate

    thanks in advanced
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  2. #2
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Any automatic changes in DB schemas outside of personal development environment are big NO-NO-NO

    Regards,
    Oleksandr

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Any automatic changes in DB schemas outside of personal development environment are big...
    so why the <prop key="hibernate.hbm2ddl.auto" > update option?

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  4. #4
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by dr_pompeii View Post
    so why the <prop key="hibernate.hbm2ddl.auto" > update option?

    regards
    To eveolve your schema during development. Small quotation from"Java Persistence with Hibernate" by Christian Bauer and Gavin King, chapter 2 page 64

    WARNING We've seen Hibernate users trying SchemaUpdate to update the schema of s production database automatically. This can quickly end in disaster and won't be allowed by your DBA.
    To make things clear - SchemaUpdate tool is tool activated by hbm2ddl.auto=true.

    Regards,
    Oleksandr

  5. #5
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

    thanks for the reply,

    wondered why this dangerous option is available is has a high risk to kill the db

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  6. #6
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by dr_pompeii View Post
    Hello

    thanks for the reply,

    wondered why this dangerous option is available is has a high risk to kill the db

    regards
    It is convinient (or at least may be convinient) during development, BTW, the whole HibernateTools package is development, not production oriented. Any decent database (I mean DB size) needs a lot of manual schema tuning to optimize performance which is DB-specific and can not be done with this tool.

    There is another reason (IMHO) the whole phylosophy of Hibernate is to provide a user with any and all imaginable options and allow him to select what suits him more. The whole book that I have mentioned is ovecrowded with statements like "Hibernate supports option XXX, but we do not reccomend to use it".

    Regards,
    Oleksandr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •