• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bulk Update with native SQL

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When our EE Application starts we must have a look if there are patch scripts (containing native sql) to update the database. In my first attempt I created a Singleton which is executed on startup. This class search the patch scripts and must execute them when needed. I read the statements of the script line for line and execute the native query with "em.createNativeQuery()". The problem is that a statement of the patchscript has mostly more than one line ;). Is there a better way to execute the statements of the patch script without parsing its content?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In my first attempt I created a Singleton which is executed on startup.


Why a Singleton?


I read the statements of the script line for line and execute the native query with "em.createNativeQuery()". The problem is that a statement of the patchscript has mostly more than one line ;). Is there a better way to execute the statements of the patch script without parsing its content?


Could you not just read the whole file and run it via JDBC?
 
reply
    Bookmark Topic Watch Topic
  • New Topic