• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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)
 
I'm doing laundry! Look how clean this tiny ad is:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic