Announcement Announcement Module
Collapse
No announcement yet.
What are the next steps to perform following database reverse engineer? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • What are the next steps to perform following database reverse engineer?

    Hi folks,

    Roo newbie here. I need to rush out a web app prototype with CRUD functionality for entities in an existing database (MySQL). I have already reverse engineered the database, and now I need to scaffold the repositories, services, Spring MVC controllers, and JSPs.

    Can someone provide a link to a howto guide that lays out how to complete these remaining steps (or enumerate the roo commands I need to issue)?

    Thank you,

    Jeff

  • #2
    I'd like to add, here is the summary of commands I've issued:

    Code:
    project --topLevelPackage com.ccs.backoffice
    jpa setup --database MYSQL --provider HIBERNATE --userName ccs_app_test --password testtest
    database properties set --key database.url -- value database.url=jdbc\:mysql://localhost:3306/ccs_test
    database reverse engineer --schema no-schema-required --testAutomatically --package ~.model --activeRecord false
    web mvc setup
    web mvc all --package ~.web
    quit
    mvn jetty:run
    However, when I browse to http://localhost:8080/backoffice, the following errors occur:

    Code:
    2012-08-16 12:19:25,858 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [/Users/jhall/Workspaces/ccs/backoffice/target/classes/META-INF/spring/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/Users/jhall/Workspaces/ccs/backoffice/target/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
            at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ...
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/Users/jhall/Workspaces/ccs/backoffice/target/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    ...
    Caused by: org.hibernate.HibernateException: Wrong column type in ccs_test.CardActionCard for column cardActionDate. Found: timestamp, expected: date
            at org.hibernate.mapping.Table.validateColumns(Table.java:283)
            at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1343)
            at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
            at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:378)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
            at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
            ... 69 more
    I'm lost at this point.

    -Jeff

    Comment


    • #3
      Originally posted by JeffH View Post
      Caused by: org.hibernate.HibernateException: Wrong column type in ccs_test.CardActionCard for column cardActionDate. Found: timestamp, expected: date
      Hi Jeff !

      In persistence.xml file modify property with name "hibernate.hbm2ddl.auto" to "none" value. I suppose your current value is "validate", and this validation fails in cardActionDate because found timestamp and expected date.

      Regards !

      Comment


      • #4
        Originally posted by mmartinez View Post
        Hi Jeff !

        In persistence.xml file modify property with name "hibernate.hbm2ddl.auto" to "none" value. I suppose your current value is "validate", and this validation fails in cardActionDate because found timestamp and expected date.

        Regards !
        Validation is on by default. Why wouldn't I want this?

        The field type for the cardActionDate column of the CardActionCard table is a timestamp. I'm still trying to find a file generated by Roo, related to the CardActionCard table that says the column is (incorrectly) a date type. Can anyone suggest where this date setting is hiding?

        Comment


        • #5
          Originally posted by JeffH View Post
          Validation is on by default. Why wouldn't I want this?
          hbm2ddl infers from the property java type the database related column type and this types mismacth on validation.

          Another solution is to modify the property java type or set with annotations the valid column type (warning, then the application will not be portable to another database).

          Comment


          • #6
            Originally posted by mmartinez View Post
            hbm2ddl infers from the property java type the database related column type and this types mismacth on validation.

            Another solution is to modify the property java type or set with annotations the valid column type (warning, then the application will not be portable to another database).
            I'm a little confused by your reply. When I looked at the generated code, it had the TIMESTAMP annotation for the cardActionDate column, and this is the type MySQL has been configured with, not "Date".

            I'm still searching the generated code to find out why it thinks it's a DATE and not a TIMESTAMP.

            Again, the database column IS a TIMESTAMP, not a DATE. And the generated code I've seen uses temporal type TIMESTAMP.

            Thanks,

            Jeff

            Comment


            • #7
              Let's close this thread. I've determined that there appears to be a bug in Roo (I'll start another thread to address it). I've discovered that Roo does NOT support scaffolding Repository and Service interfaces and implementations, and it appears that if I want to RAD up an app via DBRE, I'll have to do that myself. Probably another JIRA for a feature request there.

              -Jeff

              Comment


              • #8
                Originally posted by JeffH View Post
                When I looked at the generated code, it had the TIMESTAMP annotation for the cardActionDate column, and this is the type MySQL has been configured with, not "Date".

                I'm still searching the generated code to find out why it thinks it's a DATE and not a TIMESTAMP.

                Again, the database column IS a TIMESTAMP, not a DATE. And the generated code I've seen uses temporal type TIMESTAMP.
                Can be a @Column annotation in property. If not, relation between java type and column type is internally coded at hbm2ddl, although you can add the @Column annotation to force the database type.

                Comment

                Working...
                X