0

JPA 2.0 を使用して 1 対多の関係に新しい要素を挿入しようとすると、迷惑なエラー メッセージが表示されます。

public class Ordinateur implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "TAG")
private BigInteger tag;
@Size(max = 30)
@Column(name = "MACHINE")
private String machine;
@Size(max = 25)
@Column(name = "NOM_FABRIQUANT")
private String nomFabriquant;
@Column(name = "NUM_SERIE")
private BigInteger numSerie;
@Column(name = "ADRESSE_IP")
private BigInteger adresseIp;
// @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Column(name = "NUM_SEQ")
private BigInteger numSeq;
@Size(max = 30)
@Column(name = "SYSTEME_EXPLOITATION")
private String systemeExploitation;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 30)
@Column(name = "IDORD")
private String idord;
@OneToMany(mappedBy = "idord")
private List<Systemeexploitation> systemeexploitationList;
@OneToMany(mappedBy = "idord")
private List<Intervention> interventionList;
@OneToMany(mappedBy = "idord")
private List<Inventaire> inventaireList;

public Ordinateur() {
} //...........    

私のセッションBean:

         public void ordCreer(Ordinateur ordinateur) {
         ordinateurFacade.create(ordinateur);
        }

マネージド Bean :

       public String enregistrerOrd() throws  Exception{
       manager.ordCreer(ordinateur);
       return "OrdList";
       }

エラーは次のとおりです。

          ATTENTION: EJB5184:A system exception occurred during an invocation on EJB OrdinateurFacade, method: public void ejb.AbstractFacade.create(java.lang.Object)
          ATTENTION: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
at com.sun.ejb.containers.BaseContainer.checkExceptionClientTx(BaseContainer.java:5071)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4906)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
at $Proxy312.create(Unknown Source)
at ejb.__EJB31_Generated__OrdinateurFacade__Intf____Bean__.create(Unknown Source)
     //...
     Caused by: javax.validation.ConstraintViolationException: Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'prePersist'. Please refer to embedded ConstraintViolations for details.
     //...
     TTENTION: EJB5184:A system exception occurred during an invocation on EJB Manager, method: public void DAO.Manager.ordCreer(jpa.Ordinateur)
       ATTENTION: javax.ejb.EJBTransactionRolledbackException
at com.sun.ejb.containers.BaseContainer.mapLocal3xException(BaseContainer.java:2314)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2096)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
at $Proxy312.create(Unknown Source)
at ejb.__EJB31_Generated__OrdinateurFacade__Intf____Bean__.create(Unknown Source)

    //................
    Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
at com.sun.ejb.containers.BaseContainer.checkExceptionClientTx(BaseContainer.java:5071)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4906)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
... 80 more
      Caused by: javax.validation.ConstraintViolationException: Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'prePersist'. Please refer to embedded ConstraintViolations for details.
at org.eclipse.persistence.internal.jpa.metadata.listeners.BeanValidationListener.validateOnCallbackEvent(BeanValidationListener.java:90)
at org.eclipse.persistence.internal.jpa.metadata.listeners.BeanValidationListener.prePersist(BeanValidationListener.java:62)
at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyListener(DescriptorEventManager.java:698)

@NotNull を削除しようとしましたが、何も起こりませんでした。

4

0 に答える 0