27792

EntityManager remove throws Object: null is not a known entity type

Question:

I am trying to delete a record in the database using EntityManager. I am using EJB JPA.

It produces the error : Object: null is not a known entity type.

Here is my code:

public void deleteAppointment(int staffID, int appointmentID) { try { StaffApointmentsPK staffApointmentsPK = new StaffApointmentsPK(); staffApointmentsPK.setAppointmentId(appointmentID); staffApointmentsPK.setStaffId(staffID); StaffApointments staffApointments = staffApointmentsFacade.find(staffApointmentsPK); System.out.println("staff app type " + staffApointments); em.remove(staffApointments); em.flush();

But in my early call to the function below, it is very similar but it is working. I do not understand what is the problem because I am searching for the entity first using staffApointmentsFacade.

Here is my other function which works:

public StaffApointments getPatientAppointmentDetails(int appointmentID, int staffID) { StaffApointmentsPK staffApointmentsPK = new StaffApointmentsPK(); staffApointmentsPK.setAppointmentId(appointmentID); staffApointmentsPK.setStaffId(staffID); StaffApointments staffApointments = staffApointmentsFacade.find(staffApointmentsPK); return staffApointments; }

Any help would be appreciated. Thanks

<strong>EDIT</strong>

I solved it by switching the int staffID, int appointmentID respectively. Thanks for all your help!

Answer1:

I solved it by switching the int staffID, int appointmentID respectively. Thanks for all your help @Donovan and @ma-ve-rick

Recommend

  • How to UnitTest a Function in a mocked method
  • ExecuteScalar SQLException: scalar variable not declared
  • no instance of constructor “AcademicStaff::AcademicStaff” matches the argument list
  • Looping through the ArrayList of Model Class in Vb.net
  • Converting JSON to Dictionary by Python [duplicate]
  • How to convert Oracle Error Messages to more user-friendly messages?
  • Cocoa Swift, get/set hidden flag on files and directories
  • Joomla 3.0 creating dummy menu item
  • How to write rows asynchronously in Spark Streaming application to speed up batch execution?
  • incorrect syntax near the keyword 'AS'
  • cocoapods Sync: ld: framework not found DATAFilter, linker command failed with exit code 1
  • ModelAdmin thread-safety/caching issues
  • JQuery dialog (with button) not working in IE9
  • Character data is not passing from php to jquery
  • handlebars.js: relative paths in partials not working [duplicate]
  • Get values from foreign key table
  • Global variable in crystal reports
  • Inserting large graph data into Neo4j using py2neo WriteBatch
  • MySql - Concatenate/merge multiple columns into one column with hard codded titles
  • SQL Server row level security - many to many
  • How to compute the result of 8086 IDIV instruction?
  • BeautifulSoup find and find_all not working as expect
  • Entity Framework Raw SQL query selecting unknown columns (unknown return type)
  • How to add a fadeIn effect while changing background image using .css in Jquery
  • PyInstaller Tkinter window low resolution in App bundle, but not in app program
  • remove user from group Mac Os X (El Capitan)
  • ORA-01843: not a valid month
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Suggestions to manage Login/Logout transitions
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • JTable with a ScrollPane misbehaving
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Sorting a 2D array using the second column C++
  • failed to connect to specific WiFi in android programmatically
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?