Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7777133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:03:40+00:00 2026-06-01T18:03:40+00:00

I am trying to create an application bootstrap that will drop all the tables

  • 0

I am trying to create an application bootstrap that will drop all the tables in the application if they exist and then intialise them with fresh data.

I have created a Spring Context that loads the datasource context – however I dont know how to override the initialisation of the datasource such that the behaviour can be customised depending on how the datasource is loaded. So.. using Hibernate as my JPA implementation..

If the datasource is loaded from the application – then I would like the schemas to update:

    <persistence-unit name="myDB" transaction-type="RESOURCE_LOCAL">
    <properties>
        <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties>
</persistence-unit>

If the datasource is loaded from the bootstrap – then I need to overload this behaviour somehow so that the database is always created from scratch before fresh data is loaded:

    <persistence-unit name="myDB" transaction-type="RESOURCE_LOCAL">
    <properties>
        <property name="hibernate.hbm2ddl.auto" value="create"/>
    </properties>
</persistence-unit>

The approach I have been taking doesn’t work as I would load the datasource using the ‘update’ setting and then drop the tables if they exist before attempting to load new data. However – the tables no longer exist for writing data !

Thanks in advance

Simon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:03:42+00:00Added an answer on June 1, 2026 at 6:03 pm

    You can pass JPA properties from Spring configuration instead of persistance.xml and use placeholder that can be configured by PlaceholderConfigurer (possibly system-properties=”OVERRIDE”), or Spring profiles (since 3.1) or using Maven filtering:

    <util:map id="jpaPropertyMap" key-type="java.lang.String" value-type="java.lang.Object">
        <entry key="hibernate.hbm2ddl.auto" value="${database.ddl.mode}" />
    </util:map>
    
    <bean id="managementEntityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        p:dataSource-ref="dataSource"
        p:jpaPropertyMap-ref="jpaPropertyMap" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an application that will display all restaurants within the users
I'm trying to create an application that will let me execute a method specified
I am trying to create an application that will send out style-heavy emails and
I am trying to create an application that makes a window (external to the
I'm trying to create an application that uses the iPhone MapView (under Google Code).
I'm trying to create an application that uses c2dm service. So. First I used
I am trying to create an application on BlackBerry 9930 simulator that authenticate the
I am trying to create an application for tablets that has a main screen
I'm trying to create an application bundle for a game that uses some libraries
I'm trying to create an application that can use the android as a fax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.