• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

entityManager executing statements on system tables?

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I need to do is execute 'ALTER USER username ACCOUNT LOCK' but all I find under entityManager is executeQueries or NativeQueries...I tried executeNativeQuery and while it did not throw any exceptions (after I granted the right permissions to the account) it also did not lock the user...I suspect because I am not really doing a query. Is there a way to execute a statement or how should I do this?
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
em.createNativeQuery("ALTER USER username ACCOUNT LOCK").executeUpdate();

This should work. Ensure you are not in a transaction, or if you are commit the transaction.
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,

First of all; thank you.

I am getting a COMMIT is not allowed in a subordinate session so I suppose I am in a transaction but I am not sure what to do to correct this. This is what I have done.



I am getting this error


javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:60)
at com.bah.englink.ejb.pm.UserProfileManager$$M$d57c1113.switchUserStatus(UserProfileManager.java:2204)
at com.bah.englink.ejb.pm.UserProfileManager$$A$d57c1113.switchUserStatus(<generated>)
at com.bah.englink.ejb.pm.UserProfileManager.switchUserStatus(UserProfileManager.java:2222)
at com.bah.englink.ejb.pm.UserProfileManager_n071r6_Impl.switchUserStatus(UserProfileManager_n071r6_Impl.java:50001)
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic