2 Replies Latest reply on Jun 1, 2009 10:11 AM by peter irmstadt

    Assignment to EntityHome doesn't occur

    peter irmstadt Newbie

      Hi!


      In my Seam project I have an Entity class 'Charge'



      @Entity
      @Table(name = "daCharge")
      public class Charge implements Serializable
      {
           private static final long serialVersionUID = 1L;
           private int chargeID; //Datenbank - ID
           private String nummer; //Chargennummer
           private int bestand; //Bestand
           
           @Id @GeneratedValue
           @Column(name = "intChargeID")
           public int getChargeID() {return chargeID;}
           public void setChargeID(int chargeID) {this.chargeID = chargeID;}
           
           @Column(name = "intBestand", nullable = true)
           public int getBestand() {return bestand;}
           public void setBestand(int bestand) {this.bestand = bestand;}
      
           @Column(name = "strNummer", nullable = false)
           @NotNull
           public String getNummer() {return nummer;}
           public void setNummer(String nummer) {this.nummer = nummer;}
      
           @Override
           public int hashCode() { ... }
      
           @Override
           public boolean equals(Object obj) {...}
      }



      On a Faceletes page the user should be able to create a new Charge so I created a class that inherits from EntityHome<E>. I scoped this class to CONVERSATION because the page where the creation applies in is inside a long running conversation. To access it directly I named it 'chargeHome'.


      The code in the .xhtml looks like


      <h:inputText value="#{chargeHome.instance.nummer" required="true" />
      <s:button action="#{chargeHome.persist}" value="Create" />



      But when I try to enter something in that field and submit, I get the following error:





      Exception during request processing:
      Caused by javax.el.ELException with message: "javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: de.stest.entity.Charge.nummer"
      Caused by javax.persistence.PersistenceException with message: "org.hibernate.PropertyValueException: not-null property references a null or transient value: de.stest.entity.Charge.nummer"


      I first thought the reason might be that the instance of the EntityHome class is not properly instantiated so I added a String directly to the EntityHome class:


      @Scope(ScopeType.CONVERSATION)
      @Name("chargeHome")
      public class ChargeHome extends EntityHome<Charge>
      {
           private String test;
      
           public String persist(){
                System.out.println(nummer);
                return super.persist();
           }
      
           public void setTest(String test) {
                this.test = test;
           }
      
           public String getTest() {
                return test;
           }
      }



      When setting the inputText to that property and pressing the button the console output is NULL. For whatever reason the values of the input text aren't submitted to the class. Do you have any idea why this happens and the text I have entered in the text field is not transmitted to the class as it should?


      Thank you in advance!