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

  • Exception while running dbre artifact

    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
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validat e(
    at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi
    at org.hibernate.cfg.Configuration.buildSessionFactor y(
    at org.hibernate.cfg.AnnotationConfiguration.buildSes sionFactory(
    at org.hibernate.ejb.Ejb3Configuration.buildEntityMan agerFactory(

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


  • #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.


    • #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.


      • #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
        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( 59)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect( :2113)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionIm
        at com.mysql.jdbc.PreparedStatement.executeInternal(P
        at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre
        at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre
        at com.mysql.jdbc.PreparedStatement.executeUpdate(Pre
        at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate( 05)
        at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate( 05)
        at$GetGeneratedKey sDelegate.executeAndExtract( :94)
        at performInsert(

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



        • #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.