Announcement Announcement Module
Collapse
No announcement yet.
Exception while running dbre artifact Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception while running dbre artifact

    Hello,
    I am trying to reverse engineer a simple Mysql database schema. The reverse engineering runs fine without any exception but when I deploy it in tomcat I get the following exception

    Caused by: org.hibernate.HibernateException: Missing column: customer_number in classicmodels.customers
    at org.hibernate.mapping.Table.validateColumns(Table. java:277)
    at org.hibernate.cfg.Configuration.validateSchema(Con figuration.java:1174)
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validat e(SchemaValidator.java:139)
    at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi onFactoryImpl.java:389)
    at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1385)
    at org.hibernate.cfg.AnnotationConfiguration.buildSes sionFactory(AnnotationConfiguration.java:954)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityMan agerFactory(Ejb3Configuration.java:891)


    I have also attached the schema script and project backup.
    Please help me solve this issue.

    Thanks
    Shekhar

  • #2
    I was able to overcome this exception by changing the hibernate.ejb.naming_strategy to org.hibernate.cfg.DefaultNamingStrategy in persistence.xml. But I am still not able to persist any entity and I am getting exceptions.

    Comment


    • #3
      The latest Roo code uses the DefaultNamingStrategy for Hibernate. As for exceptions trying to persist, you will have to post more detail. DBRE's responsibility ends after the creation of legal JPA 2.0 annotations. If you think there is a problem with the annotations, please also post the details.

      Comment


      • #4
        Hello Alan,

        Thanks for your reply. I am using version 1.1.0.RELEASE [rev 793f2b0] which does not use org.hibernate.cfg.DefaultNamingStrategy. may be in next release I will be getting the change. Now my problem is that by default entities created by Roo have @GeneratedValue(strategy = GenerationType.AUTO) but on my database I don't have any auto generate enabled. As a result I am getting following exception
        Caused by: java.sql.SQLException: Field 'officeCode' doesn't have a default value
        at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:1075)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3566)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3498)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:19 59)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :2113)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionIm pl.java:2568)
        at com.mysql.jdbc.PreparedStatement.executeInternal(P reparedStatement.java:2113)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:2409)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:2327)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre paredStatement.java:2312)
        at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate(DelegatingPreparedStatement.java:1 05)
        at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate(DelegatingPreparedStatement.java:1 05)
        at org.hibernate.id.IdentityGenerator$GetGeneratedKey sDelegate.executeAndExtract(IdentityGenerator.java :94)
        at org.hibernate.id.insert.AbstractReturningDelegate. performInsert(AbstractReturningDelegate.java:57)


        Is there a way that allows me to manage key generation?

        Thanks
        Shekhar

        Comment


        • #5
          DBRE can't determine if a primary key is assigned or sequence generated because that information is not contained in the database metadata, so you will push-in refactor the @id field and make the change yourself.

          Comment

          Working...
          X