0

Both my tables are bound to their respective JTables. I have the entitymanager and all the other stuff.

I can insert into tables, but when I try to delete a record, it comes back to say that the record cannot be found or does not exist. Here's my code:

try
{
    JOptionPane.showMessageDialog(null, "It's over? What A Shame....");

    String GID = JOptionPane.showInputDialog("Enter Game Code:");

    int GameID = Integer.parseInt(GID);

    //Finding Game
    Roster r = PATMiniPUEntityManager.find(Roster.class, GameID);

    //Deleting
    PATMiniPUEntityManager.getTransaction().begin();
    PATMiniPUEntityManager.remove(r);
    PATMiniPUEntityManager.getTransaction().commit();
    System.out.println("Deleted!");



}
catch(Exception exc)
{
    System.out.println("No Game Found!");
}

I cannot find the error anywhere. The PK in the table is of type Integer.

halfer
  • 19,824
  • 17
  • 99
  • 186
GipsyD
  • 206
  • 1
  • 3
  • 16
  • Posting tips: in general, if you can write your posts as separate entities, that makes life easier for readers. If there is context (e.g. a series of posts about Derby) then mention them only if this is relevant, otherwise readers may dip into your prior posts even though they don't need to. Additionally, keeping posts as succinct and non-chatty as possible is ideal - questions and answers are a reference material for future readers, rather than just for posters. Thanks! – halfer May 11 '16 at 16:37
  • Granted that may be the case. But i am working through my project/s one bit at a time. Answers sometimes I find on my own, and some from this site. I cannot be expected to write a very long question here on this site that is relating to Derby. I am finding problems as I go along, therefore I ask so many questions. – GipsyD May 11 '16 at 19:19
  • I have never worked with Derby before, and therefore I do not know the tricks of the trade. – GipsyD May 11 '16 at 19:23
  • A large number of questions is fine (up to a point - the system will limit you if you post too often) but this was not what I was referring to specifically. It's more just general advice to keep things succinct if you can - it can sometimes mean the difference between keeping someone's attention and losing it. Anyway, good luck with your Derby work! – halfer May 11 '16 at 19:26
  • 1
    Thank you for understanding. I will definetly try my best to keep my posts short and sweet, and work on my english. Thank you for the support. I am going to need it! – GipsyD May 11 '16 at 19:29

0 Answers0