SelectOneMenu抛出数据库异常

时间:2014-03-06 13:42:33

标签: jsf-2.2

在我的应用程序中,用户必须创建一个员工列表,并在执行此操作以指定员工工作的服务时,我使用了oneSelectMenu,但在测试时会抛出数据库异常,以尝试在服务表中插入值(这是不对的,因为我试图保存employees表中的值) 这是我的员工ManagedBean代码

@ManagedBean(name="persMb")
@SessionScoped
public class PersonnelMb {
private List<ServiceInterne> serviceInternesList;
private List<Personnel> personnelsList;

private DataModel personnels;
private Integer idPers;
private ServiceInterne selectedService;
private Personnel newPersonnel = new Personnel();
private Personnel editPersonnel;
private ServiceInterneDao sDao = new ServiceInterneDao();
private PersonnelDao pDao = new PersonnelDao();

public String create() {
System.out.println("selected Service "+selectedService);
    newPersonnel.setServiceInterne(selectedService);
    pDao.ajouter(newPersonnel);
    newPersonnel = new Personnel();
    personnels.setWrappedData(pDao.selectAll());
    FacesMessage msg = new FacesMessage("Ajout effectué avec succés");
    FacesContext.getCurrentInstance().addMessage(null, msg);
    return "list";
}

这是jsf页面代码

                            <p:column>
                                <p:selectOneMenu value="#{persMb.selectedService}"
                                    converter="ServiceInterneConverter">
                                    <f:selectItems value="#{servInterMb.serviceInternesList}"
                                        var="s" itemLabel="#{s.libelle}" itemValue="#{s}">
                                    </f:selectItems>
                                </p:selectOneMenu>
                            </p:column>
                        </p:row>

这是错误的堆栈跟踪

                        2014-03-06T14:34:50.556+0100|Infos: [EL Warning]: 2014-03-06                14:34:50.555--UnitOfWork(1946319022)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
                 Internal Exception: java.sql.SQLException: ORA-00001: violation de contrainte unique (ELSA.SYS_C008545)
                 Error Code: 1
               Call: INSERT INTO Service_Interne (IDSERVICEINTER, LIBELLE, MISSION) VALUES (?, ?, ?)
bind => [3 parameters bound]
          Query: InsertObjectQuery(com.oratech.model.ServiceInterne@2140b3d2)
                2014-03-06T14:34:50.558+0100|Avertissement: #{persMb.create}: javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
       Internal Exception: java.sql.SQLException: ORA-00001: violation de contrainte unique (ELSA.SYS_C008545)
          Error Code: 1
          Call: INSERT INTO Service_Interne (IDSERVICEINTER, LIBELLE, MISSION) VALUES (?, ?, ?)
bind => [3 parameters bound]
       Query: InsertObjectQuery(com.oratech.model.ServiceInterne@2140b3d2)
            javax.faces.FacesException: #{persMb.create}: javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
         Internal Exception: java.sql.SQLException: ORA-00001: violation de contrainte unique (ELSA.SYS_C008545)
           Error Code: 1
     Call: INSERT INTO Service_Interne (IDSERVICEINTER, LIBELLE, MISSION) VALUES (?, ?, ?)
bind => [3 parameters bound]
     Query: InsertObjectQuery(com.oratech.model.ServiceInterne@2140b3d2)
at                 com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)

我的RDBMS是Oracle 10g xe,我的IDE是eclipse Kepler

0 个答案:

没有答案