2 Replies Latest reply on Jul 11, 2007 11:56 AM by Leandro Hermida

    Better debug logging during EJB3/Hibernate automatic DDL and

    Leandro Hermida Newbie

      Hi everyone,

      I am a new JBoss user and please forgive me if I missed something searching in the forums or in the docs. I looked for a while and couldn't find info on exactly my problem. I find ways to increase Hibernate logging once everything is running but not for when I deploy my ear to JBoss.

      I have written some enitty bean classes properly annotated with EJB3 annotations. To deploy and test it I have created an ear and in the persistence.xml set the Hibernate Entity Manager property hibernate.hbm2ddl.auto = create-drop. In my JBoss app server console I am getting this error during deployment

      org.hibernate.MappingException: Foreign key (FK9967C03096D4F603:ALL_EQUIPMENT [EQUIPMENT_IDC])) must have same number of columns as the referenced primary key (EQUIPMENT [GENERIC_PROTOCOL_IDC,GENERIC_EQUIPMENT_IDC])


      The error is understandable but it is not enough information to tell me where the source of the error is in my EJB3 entity bean code. Hibernate shouldn't think that the EQUIPMENT table has a composite primary key with the above columns but I cannot find where it is interpreting this and where the possible error is in my code.

      How do I get it to tell me more information?

      Thanks for the help,

      Leandro


        • 1. Re: Better debug logging during EJB3/Hibernate automatic DDL
          wayne baylor Apprentice

          as far as logging, i think you can provide a log4j.properties in your EAR to adjust the default logging.

          you should be able to identify the error in your entity annotations though.


          ps. have you looked at jboss_home/server/***/log/server.txt?

          • 2. Re: Better debug logging during EJB3/Hibernate automatic DDL
            Leandro Hermida Newbie

            Hi,

            Thanks for the help. I did end up finding out yesterday that $JBOSS_HOME/server/default/log/server.log had more detailed debugging information, particularly a DEBUG level Hibernate log. I also found that the default configuration in $JBOSS_HOME/server/default/conf/log4j.xml was filtering these messages from the console and that this could be changed there.

            I also figured out my problem below - it was a table name clash that confused Hibernate. I had a many-to-many association between two entities that accidentally had the same name as another unrelated entity. Hibernate then would create a join table of the same name and get confused when making relationships. This is something to watch out for!

            -Leandro