4 Replies Latest reply on Mar 31, 2008 9:04 AM by allanrj

    Problem with Entity Bean

    allanrj

      Hi guys,

      I got the follow error:
      javax.ejb.DuplicateKeyException: Entity with primary key br.com.gcm.ejb.cmp.SessionsKey@1b87f403 already exists

      My doubt is: I need to destroy the object or wait for garbage colector or have another way?

      I´m using jboss 4.2.2

        • 1. Re: Problem with Entity Bean
          allanrj

          well this error persist .... how can i solve this ??

          problem on ejb or configuration of jboss ?

          • 2. Re: Problem with Entity Bean
            frankthetank

            Sounds more like you have an entity with two primary keys.
            Look if you have @Id defined twice or something like that.

            • 3. Re: Problem with Entity Bean
              allanrj

              Well,

              I using a ejb to persisting the session, when i log in the ejb has been created.
              I´m close browser and try log in again, but exception has appeared.

              I think jboss doesnt destroy/remove my earlier ejb. This persists on memory
              or cache, i dont know

              • 4. Re: Problem with Entity Bean
                allanrj

                Im using ejb 2.0 on my application. Im using a session bean (façade) to access entity bean. I have follow entity: Session, to manage a user session.

                Well, when i logon, jboss using the follow commands:
                2008-03-31 10:00:05,269 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.Sessions] Executing SQL: SELECT COUNT(*) FROM SESSIONS WHERE sessionid=?
                2008-03-31 10:00:05,285 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.Sessions] Executing SQL: INSERT INTO SESSIONS (sessionid, sessioninsertdate, sessionupdatedate, sessionipnumber, userid, sessionipforwarded, sessionclientbrowser, sessioncookieid, siteid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
                2008-03-31 10:00:05,285 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.Sessions] Executing SQL: UPDATE SESSIONS SET sessioninsertdate=?, sessionupdatedate=?, sessionipnumber=?, userid=?, sessionclientbrowser=?, siteid=? WHERE sessionid=?

                Then, I close browser and try logon again and jboss do:
                2008-03-31 10:01:19,013 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.Sessions] Executing SQL: SELECT COUNT(*) FROM SESSIONS WHERE sessionid=?

                And trow a exception:
                javax.ejb.DuplicateKeyException: Entity with primary key br.com.gcm.ejb.cmp.SessionsKey@a78a01aa already exists

                Well my doubt is:
                Why object stay at memory after i close a browser ? Jboss dont manager this right ok ?