7 Replies Latest reply on Jul 9, 2002 1:45 PM by gzhong

    what is being inserted into foreign key

    gzhong

      If cmr is set up correctly in Jboss, the debug log shows a prepared statement of insert. One of the columns is the foreign key column. But what is JBoss actually inserting into that column? How does it know to insert the primary key of the referred ejb bean into that column? In what xml file is that mentioned?

      Thanks,
      G

        • 1. Re: what is being inserted into foreign key
          dsundstrom

          If you want to see what is being set or loaded into a field increase the log level to TRACE (this will create a ton of log messages).

          In the initial insert the field is set to null. All fields are initialized to Java defaults.

          • 2. Re: what is being inserted into foreign key
            gzhong

            I turned on the trace and the log has all these trace lines. On the part I am interested in, the insertion part, it goes line by line for what index it is inserting what sort of object, but at the sixth one, where the foreign key, is, there is no trace info, it's just the start of the ClassCastException. SO I don't know what what it is trying to insert into that foreign key :-(

            I hear a lot about how this is a result of not using Local beans, but how would I know if I am using local or not? My set/get are expecting to use or return Local beans, what else does JBoss want?

            G

            • 3. Re: what is being inserted into foreign key
              dsundstrom

              What does the error message say? It usually tells you the type of the current object, and the you look at the line of code to see the type to which it is trying case. If you can't figgure it out post the first few lines of the stack trace.

              • 4. Re: what is being inserted into foreign key
                gzhong

                After successfully inserting in to the first five our of six columns, I get this error. Seems like it is inserting an Object, but what object? It's a foreign key column expecting an int.

                java.lang.ClassCastException
                at oracle.jdbc.driver.OraclePreparedStatement.setObject(int,java.lang.Object,int,int) (pc 303)
                at oracle.jdbc.driver.OraclePreparedStatement.setObject(int,java.lang.Object,int) (pc 14)
                at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setObject(int,java.lang.Object,int) (LocalPreparedStatement.java:607) (pc 7)

                • 5. Re: what is being inserted into foreign key
                  dsundstrom

                  What version of oracle are you using? Also turn the log level upto trace and post the trace statement printed in the server.log file imedately before this error.

                  • 6. Re: what is being inserted into foreign key
                    gzhong

                    Hi Dain,
                    Here's what I got before the exception. I am using Oracle 8i, but the library is classes111.zip (and not classes12.zip that I see all over the posting, hope that's not the reason for I don't know where to get classes12.zip).

                    2002-07-09 09:32:47,691 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCo
                    mmand.Project] Executing SQL: INSERT INTO VECTOR_PROJECT (project_id, descriptio
                    n, name, parent_project_id, type, user_id) VALUES (?, ?, ?, ?, ?, ?)
                    2002-07-09 09:32:47,693 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
                    eldBridge.Project.projectId] Set parameter: index=1, jdbcType=INTEGER, value=41
                    2002-07-09 09:32:47,694 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
                    eldBridge.Project.description] Set parameter: index=2, jdbcType=VARCHAR, value=f
                    irst description
                    2002-07-09 09:32:47,696 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
                    eldBridge.Project.name] Set parameter: index=3, jdbcType=VARCHAR, value=first_th
                    ing
                    2002-07-09 09:32:47,696 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
                    eldBridge.Project.parentProjectId] Set parameter: index=4, jdbcType=INTEGER, val
                    ue=-1
                    2002-07-09 09:32:47,702 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
                    eldBridge.Project.type] Set parameter: index=5, jdbcType=NUMERIC, value=1
                    2002-07-09 09:32:47,713 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCo
                    mmand.Project] Could not create entity
                    java.lang.ClassCastException
                    at oracle.jdbc.driver.OraclePreparedStatement.setObject(int,java.lang.Ob
                    ject,int,int) (pc 303)
                    at oracle.jdbc.driver.OraclePreparedStatement.setObject(int,java.lang.Ob
                    ject,int) (pc 14)
                    at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setObjec
                    t(int,java.lang.Object,int) (LocalPreparedStatement.java:607) (pc 7)


                    G

                    • 7. Re: what is being inserted into foreign key
                      gzhong

                      Oh, problem solved. I found classes12.zip and replaced classes111.zip with it, and the problem went away.

                      Thanks for the tip.

                      BTW: for JBoss3.0 final, where should I put libraries? Putting them in jboss/lib/ext does not work, and I had to modify run.sh to add the libs in there to the classpath. Is there a more dynamic way?

                      Thanks,
                      G