As the title says i\'m having an annoying IllegalStateException in my spring web app. I\'ve been through numerous topics here on SO and other forums, without any luck.
T
Remove the code to get the folder
object in your controller and pass the folderName
String parameter. In your Note Service implementation class use the folderService to do the job.
Use the @Trasactional
annotation when you merge your data to the table for managing transaction,
Here's the code
@Transactional
public String insertNote(Note note, String folderName) {
try{
EntityManager em = emf.createEntityManager();
Folder folder = folderService.getFolderByName(folderName);
note.setFolder(folder);
em.flush();
em.merge(note);
}catch(Exception e){
e.printStackTrace();
}
return "Success!";
}