This content has been marked as final.
Show 2 replies
-
1. Re: Why do I need to use entityManager.flush() ?
pmuir Dec 7, 2007 6:35 AM (in response to w17chm4n)Post your SMPC version of the code.
-
2. Re: Why do I need to use entityManager.flush() ?
w17chm4n Dec 7, 2007 6:54 AM (in response to w17chm4n)@Stateful @Scope(ScopeType.APPLICATION) @Name("questionTypeManager") public class QuestionTypeManagerBean implements QuestionTypeManager { @Logger Log log; @In EntityManager entityManager; public void addQuestionType(String questionType) { entityManager.persist(new QuestionType(questionType)); entityManager.flush(); log.info("Successfuly persisted question type"); } public QuestionType getQuestionTypeByName(String questionTypeName) { return (QuestionType)entityManager.createQuery("from QuestionType q where q.questionType = '" + questionTypeName + "'").getSingleResult(); } public List<QuestionType> getAllQuestionTypes() { return entityManager.createQuery("from QuestionType qt").getResultList(); } @Remove @Destroy public void destroy() {} }