Announcement Announcement Module
Collapse
No announcement yet.
Has anyone tried Roo with Spring 2.5? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Has anyone tried Roo with Spring 2.5?

    We're in a hurry with an old project that uses Spring 2.5 and I'd like to use Spring Roo because I think it could speed up the development.

    At the beginning, I only need to create a jar project (I could create the MVC by myself)

  • #2
    Hello:

    More than 60 views! but no responses. It's either a very interesting question or a really dumb one

    My attempt was a complete failure.

    The code compiles, but in order to make the tests run with 2.5 it's necessary to change things that were corrected, fixed or improved
    - JUnit version 4.4, because 4.5 or higher doesn't work with Spring 2.5 (the 3.0 version fixed that)
    - JPA 1.0 (that is, the persistence.xml and javax.persistence.persistence-api.1.0 within the POM)
    - Hibernate 3.2.6.ga (Hibernate 4 is about to be released and here I am, stepping backwards)
    - hibernate-entitymanager: it was a headache, because I don't know what version fits well, I tried 3.3.2.GA

    Of course, it's necessary to change all the xmlns to 2.5.

    The worst part, I wasn't be able to make it run, so I give up.

    It's a pity, because it took me few hours to create an entire application with the basic entities and their relationship. Now I have to start from the square one.

    Comment


    • #3
      I wonder why not reverse engineering -dbre- the database used by the 2.5 project is an option?

      Thx
      jD
      Last edited by delgad9; Oct 24th, 2011, 07:12 AM.

      Comment


      • #4
        Thanks for the response, I appreciate the help.

        The main problem is that the tests don't work because it can't even load the application: I miss something when changing the dependencies, from the current Spring 3.0 to the previous 2.5.

        I can't figure out the entire maven dependencies needed. That is what I'm looking for with this POST. I wanted to know what I have to change in the POM/ApplicationContext in order to make the project compatible with Spring 2.5.

        At the end, the project doesn't work due to ClassNotFoundException's, NoSuchMethodError's and something like that.

        That was the reason I decided to give up.

        Furthermore, we are using DB2 as database, and I don't have an OSGI driver yet. So the reverse engineer it's not an option for now.

        Greetings

        Comment


        • #5
          Puaj.

          I don't know if it works, but at least, it passes the tests.

          In fact, it isn't Roo code working with Spring 2.5: I've "refactored" the code ("push in" all the aspects) and I've copied the code in the project that is using Spring 2.5

          All the Spring annotations are allowed in 2.5, but none of the validations, so I've substituted them with "Asserts" in the setters.

          Furthermore, the <context:spring-configured> namespace and the @Configurable annotation doesn't seem to work, the @PersistenceContext is not injected in the @Entity.

          So I've separated the @Entity in two parts: one with the POJO bean, and a new DAO class with the database operations. Annotating the latter with @Repository(), and using <context:annotation-config/>, the EntityManager is in ijected in the DAO with the @PersistenceContext and everything seems to work.

          For testing, the DataOnDemand objects are now @Component's with DAO's @Autowired. The rest remains, except a little change in the init method:

          Code:
          	public void init() {
                  data = myEntityDao.findMyEntityEntries(0, 10);
                  if (data == null) throw new IllegalStateException("Find entries implementation for 'MyEntity' illegally returned null");
                  if (!data.isEmpty()) {
                      return;
                  }
                  
                  data = new ArrayList<MyEntity>();
                  for (int i = 0; i < 10; i++) {
                      MyEntity obj = getNewTransientMyEntity(i);
                      try {
                      	myEntityDao.persist(obj);
                      } catch (ConstraintViolationException e) {
                          StringBuilder msg = new StringBuilder();
                          msg.append("[").append(e.getConstraintName()).append(":").append(e.getMessage()).append("=").append(e.getErrorCode()).append("]");
                          throw new RuntimeException(msg.toString(), e);
                      }
                      myEntityDao.flush();
                      data.add(obj);
                  }
              }
          Now the DataOnDemand has a protected DAO and the test a DataOnDemand Autowired. The last step is to change the static calls to the Entity methods, that no longer exist, for calls to the DAO using the DataOnDemand. Something like this:

          Code:
          long count = dod.myEntityDao.countMyEntities();
          
          //...
          MyEntity obj = dod.getNewTransientMyEntitiy(Integer.MAX_VALUE);
          dod.myEntityDao.persist(obj);
          dod.myEntityDao.flush();
          I'm not very proud of this, but it seems to work.

          Comment

          Working...
          X