• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Spring console application needs to modify hibernate properties

Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a legacy Spring 3.2 app.  It has a hibernate session factory with a particular set of hibernate properties that work for our j2ee deployment.  But for our test case, i want everything else in that file to be the same, but I need to set two additional properties.  How can I modify it from my console test?

  <property name="hibernateProperties">
 <prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
         <prop key="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</prop>
       <prop key="hibernate.bytecode.provider">javassist</prop>
       <prop key="hibernate.show_sql">${show_sql}</prop>
       <prop key="hibernate.cache.use_second_level_cache">${show_L2_cache}</prop>
       <prop key="hibernate.default_schema">${schema}</prop>
       <prop key="javax.persistence.validation.mode">none</prop>
       <prop key="testOnBorrow">false</prop>


I need to add those bottom two.  They don't normally exist in that file.  The below is how I am starting up, and it works, but not without those two params set.  But I only want them in the console run, not in the real file.  Is there a way I can add them just for test?

DriverManagerDataSource ds = new DriverManagerDataSource(dbUrl, dbUser, dbPass);
SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
builder.bind(dbJndi, ds);
       springCtx = new ClassPathXmlApplicationContext("WEB-INF/app-config.xml");

Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic