Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bulk Update with native SQL  RSS feed

 
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!