10 Replies Latest reply on Feb 6, 2008 5:39 PM by Nicklas Karlsson

    Please help ! Can't persist data into related tables

    Sart Valcerou Newbie

      Hello !
      I'm trying to persist some data into related tables for more then a week, but it's not working at all..
      Please Help !
      This is the code...



      package com.st.st;
      // Generated 06.02.2008 1:13:21 by Hibernate Tools 3.2.0.b10
      
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      
      import javax.persistence.GeneratedValue;
      import static javax.persistence.GenerationType.IDENTITY;
      import javax.persistence.Id;
      import javax.persistence.JoinColumn;
      import javax.persistence.ManyToOne;
      import javax.persistence.Table;
      import org.hibernate.validator.NotNull;
      
      /**
       * Info generated by hbm2java
       */
      @Entity
      @Table(name = "info", catalog = "seamtest")
      @Name("info")
      public class Info implements java.io.Serializable {
      
       private Integer infoId;
       private User user;
       private int infoFullPayment;
      
       public Info() {
       }
      
       public Info(User user, int infoFullPayment) {
       this.user = user;
       this.infoFullPayment = infoFullPayment;
       }
      
       @Id
       @GeneratedValue(strategy = IDENTITY)
       @Column(name = "info_id", unique = true, nullable = false)
       public Integer getInfoId() {
       return this.infoId;
       }
      
       public void setInfoId(Integer infoId) {
       this.infoId = infoId;
       }
       @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumn(name = "user_id", nullable = false)
       @NotNull
       public User getUser() {
       return this.user;
       }
      
       public void setUser(User user) {
       this.user = user;
       }
      
       @Column(name = "info_full_payment", nullable = false)
       @NotNull
       public int getInfoFullPayment() {
       return this.infoFullPayment;
       }
      
       public void setInfoFullPayment(int infoFullPayment) {
       this.infoFullPayment = infoFullPayment;
       }
      
      }
      


      package com.st.st;
      // Generated 06.02.2008 1:13:21 by Hibernate Tools 3.2.0.b10
      
      import java.util.HashSet;
      import java.util.Set;
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.GeneratedValue;
      import static javax.persistence.GenerationType.IDENTITY;
      import javax.persistence.Id;
      import javax.persistence.OneToMany;
      import javax.persistence.Table;
      import org.hibernate.validator.NotNull;
      
      /**
       * User generated by hbm2java
       */
      @Entity
      @Table(name = "user", catalog = "seamtest")
      @Name("user")
      public class User implements java.io.Serializable {
      
       private Integer userId;
       private int userPayment;
       private Set<Info> infos = new HashSet<Info>(0);
      
       public User() {
       }
      
       public User(int userPayment) {
       this.userPayment = userPayment;
       }
       public User(int userPayment, Set<Info> infos) {
       this.userPayment = userPayment;
       this.infos = infos;
       }
      
       @Id
       @GeneratedValue(strategy = IDENTITY)
       @Column(name = "user_id", unique = true, nullable = false)
       public Integer getUserId() {
       return this.userId;
       }
      
       public void setUserId(Integer userId) {
       this.userId = userId;
       }
      
       @Column(name = "user_payment", nullable = false)
       @NotNull
       public int getUserPayment() {
       return this.userPayment;
       }
      
       public void setUserPayment(int userPayment) {
       this.userPayment = userPayment;
       }
       @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
       public Set<Info> getInfos() {
       return this.infos;
       }
      
       public void setInfos(Set<Info> infos) {
       this.infos = infos;
       }
      
      }
      
      


      package com.st.st;
      
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      
      import com.st.st.insert;
      @Name("insert")
      public @Stateless class insertBean implements insert {
       @In private User user;
       @In private Info info;
       @PersistenceContext private EntityManager em;
      
       public void insert(Integer userPayment, Integer infoFullPayment){
      
       Info info = new Info();
       info.setInfoFullPayment(infoFullPayment);
      
       User user = new User();
       userPayment = infoFullPayment*2;
       user.setUserPayment(userPayment);
      
       info.setUser(user);
       em.persist(info);
       }
      
      }
      


      package com.st.st;
      
      import javax.ejb.Local;
      
      @Local
      public interface insert {
       public void insert(Integer userPayment, Integer infoFullPayment);
      
      }
      


      
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:a="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich"
       template="layout/template.xhtml">
      
      <ui:define name="body">
      
      <h:form>
       <h:inputText value="#{info.infoFullPayment}"/>
       <h:commandButton value="push" action="#{insert.insert}"/>
      </h:form>
       </ui:define>
      
      </ui:composition>
      


        • 1. Re: Please help ! Can't persist data into related tables
          Nicklas Karlsson Master

          And the error you see is...?

          You seem to be calling #{insert.insert}. Which means that the method "insert" in the seam named component "insert" is being called. You shouldn't have any parameters in the method. Remove them from the local interface and then inject the beans (info?) into the insert bean.

          That way the bound value from the user input is accessible to the insert method.

          When the concept is new it is recommended to spend the week like "one day reading the documentation, six days for tweaking the provided examples" and not "seven days frantic, random coding" ;-)

          • 2. Re: Please help ! Can't persist data into related tables
            Sart Valcerou Newbie

            Thank you for your reply !
            but i don't know how to do this, can you support me with some code that shows how to "inject the beans (info?) into the insert bean".

            • 3. Re: Please help ! Can't persist data into related tables
              Sart Valcerou Newbie

              and here is an exaption..

              Exception during request processing:
              Caused by javax.servlet.ServletException with message: "#{insert.insert}: javax.el.MethodNotFoundException: /insert.xhtml @17,59 action="#{insert.insert}": Method not found: insertBean.insert()"
              javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
              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.MultipartFilter.doFilter(MultipartFilter.java:85)
              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:44)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
              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:230)
              org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
              org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
              org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              java.lang.Thread.run(Thread.java:619)Caused by javax.faces.FacesException with message: "#{insert.insert}: javax.el.MethodNotFoundException: /insert.xhtml @17,59 action="#{insert.insert}": Method not found: insertBean.insert()"
              com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:99)
              javax.faces.component.UICommand.broadcast(UICommand.java:383)
              org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
              org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
              org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
              com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
              com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
              com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
              javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
              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.MultipartFilter.doFilter(MultipartFilter.java:85)
              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:44)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
              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:230)
              org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
              org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
              org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              java.lang.Thread.run(Thread.java:619)Caused by javax.faces.el.MethodNotFoundException with message: "javax.el.MethodNotFoundException: /insert.xhtml @17,59 action="#{insert.insert}": Method not found: insertBean.insert()"
              javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapt
              er.java:81)
              com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
              javax.faces.component.UICommand.broadcast(UICommand.java:383)
              org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
              org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
              org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
              com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
              com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
              com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
              javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
              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.MultipartFilter.doFilter(MultipartFilter.java:85)
              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:44)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
              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:230)
              org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
              org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
              org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              java.lang.Thread.run(Thread.java:619)Caused by javax.el.MethodNotFoundException with message: "/insert.xhtml @17,59 action="#{insert.insert}": Method not found: insertBean.insert()"
              com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:72)
              javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapt
              er.java:77)
              com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
              javax.faces.component.UICommand.broadcast(UICommand.java:383)
              org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
              org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
              org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
              com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
              com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
              com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
              javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
              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.MultipartFilter.doFilter(MultipartFilter.java:85)
              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:44)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
              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:230)
              org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
              org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
              org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              java.lang.Thread.run(Thread.java:619)
              


              • 5. Re: Please help ! Can't persist data into related tables
                Jason Long Master

                Why don't you start with one of the examples until you have a better understanding of how Seam works?

                I realize that there is a learning curve to this framework, but it is well worth it once you get rolling.

                • 6. Re: Please help ! Can't persist data into related tables
                  Sart Valcerou Newbie

                  but there are no examples that shows how to manipulate with data in related tables

                  • 7. Re: Please help ! Can't persist data into related tables
                    Jason Long Master

                    Then modify one that so that is does.

                    At least it will be working and you can see what you are doing wrong, or the Seam developers who are familiar with the examples might see your problem.

                    I pointed out why you were getting the exception that you posted.

                    Have you tried persisting the BillingInfo first and then adding it to User and then persisting the User?

                    • 8. Re: Please help ! Can't persist data into related tables
                      Sart Valcerou Newbie

                      Thanks for your reply.
                      But probably i'm to dumb to code using seam...

                      • 9. Re: Please help ! Can't persist data into related tables
                        Jason Long Master

                        I doubt you are too dumb.

                        I have been using Seam since 1.0 beta.

                        Seam is a powerful technology and has a learning curve. Keep at it and you will be satisfied when you are using it.

                        • 10. Re: Please help ! Can't persist data into related tables
                          Nicklas Karlsson Master

                          POJO quick and dirty style:

                          Let's say you have an entity

                          @Entity
                          public class User {
                           @Id @GeneratedValue
                           private long id;
                           private String name;
                          
                           public long getId() {
                           return id;
                           }
                          
                           public void setId(long id) {
                           this.id = id;
                           }
                          
                           public String getName() {
                           return name;
                           }
                          
                           public void setName(String name) {
                           this.name = name;
                           }
                          }
                          


                          and then an action class (you could save a few lines by extending EntityController)

                          @Name("userActions")
                          public class UserActions {
                           @In
                           private EntityManager entityManager;
                           @In
                           private FacesMessages facesMessages;
                          
                           private User user = new User();
                          
                           public void insert() {
                           entityManager.persist(user);
                           facesMessages.add("Added user #0", user.getName());
                           }
                          
                           public User getUser() {
                           return user;
                           }
                          
                           public void setUser(User user) {
                           this.user = user;
                           }
                          }
                          


                          and the view

                           <h:messages globalOnly="true" styleClass="message"/>
                           <h:form>
                           <h:inputText value="#{userActions.user.name}"/>
                           <h:commandButton action="#{userActions.insert}" value="Insert!"/>
                           </h:form>
                          


                          For each click on the button, the userActions.insert is called. Since the input text is connected to userActions.user.name, it populates the newly created entity in the bean and persist has something to work on.

                          If you would have a
                          Name("user")
                          


                          on the user class, you would have linked the input field to user.name and then injected the user into the userAction bean with

                          @In(create=true)
                          private User user;
                          


                          and persist would then have had something to work on. Likewise, if the entity resides in another bean, you connect the input field to someotherbean.user.name and then inject that bean (or the user from that bean) using the @In annotation again. So that your action class has some data to work on.

                          It is really worth to give the in/outjection part of the manual a good read since it is pretty much the core of the framework...