[jboss-user] [JBoss Seam] - Re: Why do I need to use entityManager.flush() ?

w17chm4n do-not-reply at jboss.com
Fri Dec 7 06:54:04 EST 2007


@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() {}
  |     
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111193#4111193

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111193



More information about the jboss-user mailing list