2 Replies Latest reply on May 20, 2010 2:24 PM by bsgcic

    Entity with private key - not-null property references a null or transient value

    bsgcic Newbie

      Can someone help me with this error? I have been searching for solutions to this problem to no avail. I am trying to add to a table which has an embedded private key.


      I get the following error:


      not-null property references a null or transient value



      Here is the persist code:


      contactFormsLocale.setContactFormsLocalePK(new ContactFormsLocalePK(contactForm, userSettings.getViewLocale()));
      entityManager.persist(contactFormsLocale);
      



      Portions of the embeddable ContactFormsLocalePK class:


      @Embeddable
      public class ContactFormsLocalePK implements Serializable
      
      private ContactForm contactForm;
      private Locale locale;
      
      public ContactFormsLocalePK() {}
      
      public ContactFormsLocalePK(ContactForm contactForm, Locale locale)
      {
           this.contactForm = contactForm;
           this.locale = locale;
      }
      
      @ManyToOne
      @NotNull
      @JoinColumn(name="contactFormAutoIdInt", insertable=true, updatable=true)
      public ContactForm getContactForm()
      {
           return contactForm;
      }
      
      public void setContactForm(ContactForm contactForm)
      {
           this.contactForm = contactForm;
      }
      
      @ManyToOne
      @NotNull
      @JoinColumn(name="localeAutoIdInt", insertable=true, updatable=true)
      public Locale getLocale()
      {
           return locale;
      }
      
      public void setLocale(Locale locale)
      {
           this.locale = locale;
      }
      
      @Override
      public int hashCode()
      {
           return (int) contactForm.hashCode() + locale.hashCode();
      }
      
      
      @Override
      public boolean equals(Object obj)
      {
           if (obj == this) return true;
           if (!(obj instanceof ContactFormsLocalePK)) return false;
           if (obj == null) return false;
           ContactFormsLocalePK pk = (ContactFormsLocalePK) obj;
           return pk.contactForm == contactForm && 
           pk.locale == locale;
      }
      
      




      Portions of the embeddable ContactFormsLocale class:


      @EmbeddedId
      public ContactFormsLocalePK getContactFormsLocalePK()
      {
           return contactFormsLocalePK;
      }
      
      public void setContactFormsLocalePK(ContactFormsLocalePK contactFormsLocalePK)
      {
           this.contactFormsLocalePK = contactFormsLocalePK;
      }
      
      
      @Transient
      public ContactForm getContactForm()
      {
           return contactFormsLocalePK.getContactForm();
      }
      
      
      @Transient
      public Locale getLocale()
      {
           return contactFormsLocalePK.getLocale();
      }
      
      
      @NotNull
      @SequenceGenerator(name="contactFormsLocales_automaticNumberInt_seqIdentifier", sequenceName="contactformslocales_automaticnumberint_seq", allocationSize=1)
      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="contactFormsLocales_automaticNumberInt_seqIdentifier")
      @Column(name="automaticNumberInt", unique=true, columnDefinition="bigserial")
      public Long getId()
      {
           return id;
      }
      
      public void setId(Long id)
      {
           this.id = id;
      }
      




      Portions of the embeddable ContactForm class:


      public ContactForm() {}
      public ContactForm(Long id)
      {
           this.id = id;
      }
      
      @Id
      @NotNull
      @SequenceGenerator(name="contactForms_automaticNumberInt_seqIdentifier", sequenceName="contactforms_automaticnumberint_seq", allocationSize=1)
      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="contactForms_automaticNumberInt_seqIdentifier")
      @Column(name="automaticNumberInt", unique=true, columnDefinition="bigserial")
      public Long getId()
      {
           return id;
      }
         
      public void setId(Long id)
      {
           this.id = id;
      }
         
      @Column(name="emailStr")
      public String getEmailStr()
      {
           return emailStr;
      }
      
      public void setEmailStr(String emailStr)
      {
           this.emailStr = emailStr;
      }
      



      Any help or thoughts would be greatly appreciated.


      Thanks,


      Jeff

        • 1. Re: Entity with private key - not-null property references a null or transient value
          bsgcic Newbie

          correction of a typo:


          ... which has an embedded primary key.

          • 2. Re: Entity with private key - not-null property references a null or transient value
            bsgcic Newbie

            Here's a more complete error message:


            Exception during request processing: 
            Caused by javax.servlet.ServletException with message: 
            "#{contactFormSubmission.register}: javax.ejb.EJBException: 
            javax.persistence.PersistenceException: 
            org.hibernate.PropertyValueException: 
            not-null property references a null or transient value: 
            com.mysite.entity.ContactFormsLocale.id"
            
            javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
            org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
            org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
            org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
            org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
            org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
            org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
            org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
            org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
            org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
            org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
            org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
            org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
            org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
            org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:384)
            org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            java.lang.Thread.run(Unknown Source)
            
            
            
            Caused by org.hibernate.PropertyValueException with message: 
            "not-null property references a null or transient value: 
            com.mysite.entity.ContactFormsLocale.id"
            
            



            Jeff