0 Replies Latest reply on Jan 15, 2008 11:22 AM by Chip Schoch

    Sybase char(1) causes exception

    Chip Schoch Novice

      I have several columns that are char(1) in sybase. If I set then to a space the try to fetch I get:

      java.lang.StringIndexOutOfBoundsException: String index out of range: 0
       at java.lang.String.charAt(String.java:558)
       at org.hibernate.type.CharacterType.get(CharacterType.java:29)
       at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
       at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
       at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
       at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096)
       at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
       at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
       at org.hibernate.loader.Loader.getRow(Loader.java:1206)
       at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
       at org.hibernate.loader.Loader.doQuery(Loader.java:701)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
       at org.hibernate.loader.Loader.doList(Loader.java:2220)
       at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
       at org.hibernate.loader.Loader.list(Loader.java:2099)
       at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
       at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
       at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
       at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
       at com.eLynx.Authentication.CustomerPrincipal.<init>(CustomerPrincipal.java:57)
       at com.eLynx.Authentication.WebappAuthenticationHandler.handle(WebappAuthenticationHandler.java:94)
       at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(LoginContext.java:955)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext$SecureCallbackHandler.handle(LoginContext.java:951)
       at com.eLynx.Authentication.CustAdminLoginModule.login(CustAdminLoginModule.java:113)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
       at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
       at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
       at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
       at com.eLynx.Controller.USignAdmin.AuthenticationController.login(AuthenticationController.java:324)
       at com.eLynx.Controller.USignAdmin.AuthenticationController.loginAdminUser(AuthenticationController.java:453)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at com.eLynx.Dispatch.XmlDispatcher.dispatch(XmlDispatcher.java:191)
       at com.eLynx.Dispatch.XmlDispatcher.dispatch(XmlDispatcher.java:105)
       at com.eLynx.Servlet.XmlWebappServlet.doPost(XmlWebappServlet.java:108)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at com.eLynx.Filter.ELynxRedirectFilter.doFilter(ELynxRedirectFilter.java:77)
       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.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       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:262)
       at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:419)
       at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:378)
       at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
       at java.lang.Thread.run(Thread.java:595)
      2008-01-15


      Apparently the jtds driver interprets the single space as an empty string because sybase respresents empty strings as single spaces. Hibernate assumes there is a character at [0] and tries to address it to construct a Character and it blows.

      Any fix for this?