Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bulk Update with native SQL

 
Sven Moschel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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?
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!