Saving Database Entities in onDisable()

Discussion in 'Plugin Development' started by AbdulAbdalla, Jan 11, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    AbdulAbdalla

    Hey,
    saving my database entities in onDisable() (called because the server is shutting down), always raises an OptimisticLockException on my productive server. But its working on my test system. Both of them are connected to a local MySQL database. Its really annying with this **** ebean implementation.
    And no: I dont access my entities from an other thread than the main thread (via. sheduleSyncDelayedTask).
    Any ideas how to avoid the exception? sheduleSyncDelayed task is not working in the onEnable() method because it not seems to be executed because the server is shutting down too fast.
    Please help me! And do you know any alternative but similar database frameworks?
    Best regards
     
  2. Offline

    Nitnelave

    Why do you want to schedule a delayed task? why not run the code from the onDisable()?

    Otherwise, just put your code in a try/catch block, stuck in a while loop, and while there's the exception, you try to do the operation again. That way, you're sure that everything gets written.
     
Thread Status:
Not open for further replies.

Share This Page