我正在使用休眠4版本。尝试使用以下代码持久化实体:
if(surveyUserRequestTO!=null){
surveyUser = new SurveyUser();
surveyUser.setAdmin(surveyUserRequestTO.getAdmin());
surveyOrganization = getEntityManager().find(SurveyOrg.class, surveyUserRequestTO.getOrganizationID());
if(surveyOrganization !=null){
surveyUser.setSurveyOrg(surveyOrganization);
}else{
return null;
}
surveyUser.setUserName(surveyUserRequestTO.getUserName());
surveyUser.setUserSurveyID(surveyUserRequestTO.getSurveyUserID());
getEntityManager().persist(surveyUser);
我收到以下异常:
JBAS014134: EJB Invocation failed on component NewUserDataProvider for
method public
com.alt.survey.user.transport.output.SurveyUserResponseTO
com.alt.survey.user.dataprovider.NewUserDataProvider.createNewUser(com.alt.survey.user.transport.input.SurveyUserRequestTO)
throws java.lang.Exception: javax.ejb.EJBException: Transaction
present on server in Never call (EJB3 13.6.2.6)
我认为这与TransactionAttribute属性有关。任何可能的帮助将非常可贵。
最佳答案
您在代码中的任何地方都没有交易属性(请参见stacktrace)。您不能使用NEVER事务属性在EJB方法中启动事务