0 Replies Latest reply on Apr 2, 2009 11:32 AM by Asif Akram

    Primary Key of Binary Data Type

    Asif Akram Newbie
      I am developing a Web application against existing database. The tables in the database have Primary Keys of type Binary. I am using MySQL database. Database schema designers decided for Binary data type for optimized indexing of primary keys (I am not sure if this is valid point). I can generate entities from Eclipse plugin but there is some type of mismatch. My sample table is:
      Create table PN_PEERSONA (
           PEERSONA_UUID Binary(20) NOT NULL,
           FIRST_NAME Varchar(255),
           LAST_NAME Varchar(255),
           BIRTH_DATE Date,
           PREFIX Varchar(255),
           DATE_CREATED Datetime,
           IS_BARRED Smallint UNSIGNED,
           IS_AUTHENTICATED Smallint,
           LAST_USER_ACTIVITY Datetime,
           PEERSONA_LOGIN Varchar(255),
           PEERSONA_PASSWORD_ENC Binary(128),
           UNIQUE (PEERSONA_UUID),
      Primary Key (PEERSONA_UUID)) ENGINE = MyISAM;

      Table has two columns PEERSONA_UUID (PK)  and PEERSONA_PASSWORD_ENC as Binary. Entity "PnPeersona" is generated correctly with following fields:
               private byte[] peersonaUuid;
           private String firstName;
           private String lastName;
           private Date birthDate;
           private String prefix;
           private Date dateCreated;
           private Short isBarred;
           private Short isAuthenticated;
           private Date lastUserActivity;
           private String peersonaLogin;
           private byte[] peersonaPasswordEnc;

      The mismatch is in PnPeersonaHome for the following code:
      public void setPnPeersonaPeersonaUuid([B id)
          {
              setId(id);
          }

          public [B getPnPeersonaPeersonaUuid()
          {
              return ([B) getId();
          }

      It is obvious system can't understand data type "[B", so I changed it to bytes[] at least compilation errors sorted out. Now the issue is no matter whatever I enter for the peersonaUuid in the Web form I have validation error "Value is required". I have tried different options like creating two transient fields of type String in the PnPeersona entity and using their getter and setter to retrieve or assign values to binary data fields. This helped me to cross the validation stage of the Web form but throws exceptions:
      10:25:10,693 ERROR [SeamPhaseListener] uncaught exception
      javax.el.ELException: java.lang.IllegalArgumentException: argument type mismatch
           at javax.el.BeanELResolver.setValue(BeanELResolver.java:116)
           at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
           at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:100)
           at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
           at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
           at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
           at org.jboss.seam.core.Expressions$1.setValue(Expressions.java:116)
           at org.jboss.seam.navigation.Pages.applyConvertedValidatedValuesToModel(Pages.java:796)
           at org.jboss.seam.navigation.Pages.postRestore(Pages.java:409)
           at org.jboss.seam.jsf.SeamPhaseListener.postRestorePage(SeamPhaseListener.java:544)
           at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:390)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:226)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
           at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
           at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
           ... 54 more

      I can confirm that entities are created but it is the PnPeersona.seam page throwing exceptions and can't display the values of just created entity, though they can be viewed from PnPeersonaList.seam. I was wondering if I am doing something wrong or it is bug in the SEAM Framework to handle field of data type Binary.

      Any help will be appreciated.

      Cheers
      Asif