Announcement Announcement Module
Collapse
No announcement yet.
sets and jsp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • sets and jsp

    Hello,

    If in roo shell i do:
    add field set jpa -class ~.key.ProductGroup -fieldName postfixes -element ~.key.Postfix -mappedBy productGroup -notNull
    in my jsp i then have:
    Code:
    <c:if test="${not empty sets}">
    <label for="_postfixes">Postfixes:</label>
    <form:select cssStyle="width:250px" id="_postfixes" path="postfixes">
    <form:options itemValue="id" items="${sets}"/>
    </form:select>
    <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "_postfixes", widgetType: "dijit.form.MultiSelect")); </script>
    </c:if>
    If i manually replace every occurence of sets by postfixes it seems to work, otherwise it won't. Is this by design, a bug or am i missing something?

    Regards,

    Ronald Vermeire

  • #2
    Hello,

    Just an addition to my own post. With
    -mappedBy productGroup
    The choosen postfix will not be persisted when i leave it out it is persisted. Again the question. By design, a bug or am i missing something.

    Kind Regards,

    Ronald Vermeire

    Comment


    • #3
      Hello,

      Another addition/bug. It only is persisted the first time! To reproduce....

      Created this class:

      Code:
      @Entity
      @RooEntity
      @RooJavaBean
      @RooToString
      public class Postfix {
      
          @NotNull
          @Size(max = 3)
          private String code;
      }

      Identical for prefix.

      I have this class ProductGroup:
      Code:
      @Entity
      @RooEntity
      @RooJavaBean
      @RooToString
      public class ProductGroup {
      
          @NotNull
          @Size(min = 4, max = 4)
          private String index;
      
          @NotNull
          @OneToMany(cascade = CascadeType.ALL)
          private Set<Prefix> prefixes = new HashSet<Prefix>();
      
          @NotNull
          @OneToMany(cascade = CascadeType.ALL)
          private Set<Postfix> postfixes = new HashSet<Postfix>();
      }

      When i create 1 pre- and 1 postfix i can save productgroup once, when i create 2 pre- and 2 postfixes i can save twice etc.


      After that i get this error(abbreviated because of max text length):


      org.springframework.transaction.TransactionSystemE xception: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while commiting the transaction at org.springframework.orm.jpa.JpaTransactionManager. doCommit(JpaTransactionManager.java:469) at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:731) at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:700) at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:322) at org.springframework.transaction.aspectj.AbstractTr ansactionAspect.ajc$afterReturning$org_springframe work_transaction_aspectj_AbstractTransactionAspect $3$2a73e96c(AbstractTransactionAspect.aj:78) at com.nxp.pkg.key.ProductGroup_Roo_Entity.ajc$interM ethod$com_nxp_pkg_key_ProductGroup_Roo_Entity$com_ nxp_pkg_key_ProductGroup$persist(ProductGroup_Roo_ Entity.aj:37) at com.nxp.pkg.key.ProductGroup.persist(ProductGroup. java:1) at com.nxp.pkg.key.ProductGroup_Roo_Entity.ajc$interM ethodDispatch1$com_nxp_pkg_key_ProductGroup_Roo_En tity$com_nxp_pkg_key_ProductGroup$persist(ProductG roup_Roo_Entity.aj) at com.nxp.pkg.web.ProductGroupController_Roo_Control ler.ajc$interMethod$com_nxp_pkg_web_ProductGroupCo ntroller_Roo_Controller$com_nxp_pkg_web_ProductGro upController$create(ProductGroupController_Roo_Con troller.aj:14) at com.nxp.pkg.web.ProductGroupController.create(Prod uctGroupController.java:1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.doInvokeMethod(HandlerMethodInv oker.java:626) at org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:150) at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:354) at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:342) at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:763) at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:709) at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:613) at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:536) at javax.servlet.http.HttpServlet.service(HttpServlet .java:637) at javax.servlet.http.HttpServlet.service(HttpServlet .java:717) at
      .................................................. .................................................
      org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:246) ... 107 more Cookies: JSESSIONID=[97623220D7AB98E453E08939F3D5E01F]


      Hope you can reproduce it.....


      Kind regards,

      Ronald Vermeire

      Comment


      • #4
        Hi Ronald,

        I have been able to replicate the problems you described. However, it would be really helpful if you could provide some details about your environment you are working in, namely:

        - Roo version
        - Java version
        - OS type and version
        - ideally a short roo script of commands to replicate the issue.

        The latter is really important as one of the problems is related to the persistence provider. So if you tell us you used the 'install jpa -provider HIBERNATE -database HYPERSONIC_IN_MEMORY' command we would know you have issues with Hibernate or the HSQL db.

        Now to your problems . Basically, I identified three issues. In short, one is an old roo bug which can be resolved by updating to Roo M2, another one is a new bug (which I fixed just now), and the third appears to be a bug in Hibernate .

        Long version:

        First, it appears you are using Roo M1 or earlier which caused the wrong naming of the attribute passed in to the jsps ('sets' in this case). If you just use Roo M2 or higher on your existing project, it will actually fix the problems automatically whithout any need for you to fix your jsps manually.

        Second, there is a problem with dojo MultiSelect boxes via Spring JS. I have opened a bug report for this: ROO-143 and the issue is resolved in the trunk and should be available in the next Roo release (unless you build Roo from sources to test it yourself ).

        Third, the TransactionSystemException you pasted below appears to be a Hibernate issue. We need to research this a little more. Switching the ormProvider to OPENJPA has resolved the issue for me:

        Code:
        update jpa -database HYPERSONIC_IN_MEMORY -provider OPENJPA
        Hope this helps.

        -Stefan

        Comment


        • #5
          Hi Stefan,

          Thnx, that helps a lot. But raises one more question: I like to work in STS which comes bundled with M1. How easy is it to switch to the latest ROO version (Ideally SVN)?

          Here are my details

          - Roo version - M1
          - Java version - 1.5.0_12
          - OS type and version - Microsoft Windows XP Proffesional v2002 sp3
          - ideally a short roo script of commands to replicate the issue.
          install jpa -provider HIBERNATE -database HYPERSONIC_PERSISTENT

          add dependency -groupId javax.annotation -artifactId jsr250-api -version 1.0

          new persistent class jpa -name ~.key.Prefix -testAutomatically
          new persistent class jpa -name ~.key.Postfix -testAutomatically
          new persistent class jpa -name ~.key.ProductGroup -testAutomatically

          add field string -class ~.key.Prefix -fieldName code -notNull -sizeMax 3
          add field string -class ~.key.Postfix -fieldName code -notNull -sizeMax 3
          add field string -class ~.key.ProductGroup -fieldName index -notNull -sizeMin 4 -sizeMax 4

          add field reference jpa -class ~.key.Prefix -fieldName productGroup -type ~.key.ProductGroup
          add field reference jpa -class ~.key.Postfix -fieldName productGroup -type ~.key.ProductGroup

          new integration test

          new controller automatic -name ~.web.PrefixController -formBackingObject ~.key.Prefix
          new controller automatic -name ~.web.PostfixController -formBackingObject ~.key.Postfix
          new controller automatic -name ~.web.ProductGroupController -formBackingObject ~.key.ProductGroup


          new selenium test -controller ~.web.PrefixController
          new selenium test -controller ~.web.PostfixController
          new selenium test -controller ~.web.ProductGroupController
          One more question i want to use Roo witch tc server and clustering enabled. Does a Roo generated webapp meet these requirements: http://static.springsource.com/proje...pscluster.html @Web Application Requirements when Using Session Replication

          Kind Regards,

          Ronald Vermeire

          Comment


          • #6
            Hi Ronald,

            Thanks for the details. This confirms my guesses about the ORM provider you used. The workarounds I suggested should solve your problems then .

            As for Roo STS integration, the M2 release of Roo ships with the RC1 release of STS and we highly recommend using this latest release of STS (see here). This release of STS also allows you to change your versions of Spring Roo (right click on the project to get to properties > Spring ...).

            Finally if you wish to build Roo from sources to get the latest features you will need to have a SVN command line client installed. I have tested this with the Collabnet Windows client. Also you will need to have Apache maven 2.0.9 or higher installed.

            Then you can create a new folder and run the following commands:

            Code:
            svn co https://src.springsource.org/svn/spring-roo/trunk spring-roo
            cd spring-roo
            mvn clean install assembly:assembly 
            cd target
            In the target directory you will find the generated RC1 release zip file which you can unpack somehwere conventient and point STS to.

            HTH,

            -Stefan

            Comment

            Working...
            X