Hi,
I use annotation and the Java type of the field is "Character" which
is handled by the "ValueStringFixed" type of H2.
The complete stack trace is:

Exception in thread "main" 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:52)
        at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184)
        at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:173)
        at org.hibernate.type.AbstractType.hydrate(AbstractType.java:105)
        at
org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:
2114)
        at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1404)
        at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332)
        at org.hibernate.loader.Loader.getRow(Loader.java:1230)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
        at org.hibernate.loader.Loader.doQuery(Loader.java:724)
        at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
259)
        at org.hibernate.loader.Loader.doList(Loader.java:2232)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
        at org.hibernate.loader.Loader.list(Loader.java:2124)
        at
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:
118)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
        at
be.ucm.cas.signaletique.vm.dao.hibernate.InarecHibernateDAO.getInarecWithNiss(InarecHibernateDAO.java:
43)
        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
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:
307)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:
182)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
149)
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:
106)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
171)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
204)
        at $Proxy54.getInarecWithNiss(Unknown Source)
        at
be.ucm.cas.preaffiliation.ti.service.impl.PreAffiliationServiceImpl.getInarecWithNiss(PreAffiliationServiceImpl.java:
848)
        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
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:
307)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:
182)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
149)
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:
106)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
171)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
204)
        at $Proxy71.getInarecWithNiss(Unknown Source)
        at
be.ucm.cas.preaffiliation.societe.batch.AffiliationSociete.launch(AffiliationSociete.java:
125)
        at
be.ucm.cas.preaffiliation.societe.batch.AffiliationSociete.main(AffiliationSociete.java:
1172)
        at
be.ucm.cas.preaffiliation.societe.batch.AffiliationSociete.main(AffiliationSociete.java:
1145)
        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.intellij.rt.execution.application.AppMain.main(AppMain.java:
110)

The class containing the problematic mapping is Inarec and the mapping
itself is

        private Character trt; // Pour savoir qui traite le flux
        @Column(name="TRT")
        public Character getTrt() {
                return trt;
        }

Hibernate config is:
    <bean
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
id="sessionFactory">
        <property name="dataSource" ref="datasource"/>
        <property name="entityInterceptor">
            <ref bean="myTstInterceptor"/>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.cache.use_query_cache">true</
prop>
                <prop
key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</
prop>
                <prop
key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
                <prop key="hibernate.jdbc.batch_size">20</prop>
                <prop
key="hibernate.jdbc.use_streams_for_binary">true</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.use_sql_comments">true</prop>
            </props>
        </property>
        <property name="annotatedClasses">
            <list>
                <value>e.ucm.cas.signaletique.vm.model.Inarec</value>
            </list>
        </property>
   </bean>

With following data source config:
        <bean name="datasource"
                class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="org.h2.Driver"/>
        <property name="url" value="jdbc:h2:/Projects/DB/h2db/dbSrv"/>
        <property name="username" value="sa"/>
        <property name="password" value=""/>
        </bean>

The problem only occurs whenever the value of the TRT column is " " (a
single space) because it's trimmed by the "ValueStringFixed.get(String
s)" method first and then the first character is taken.......
The Hibernate version is "3.3.2-GA".

Thanks for your help,

  Michel


On 19 avr, 07:14, Thomas Mueller <[email protected]> wrote:
> Hi,
>
> Normally Hibernate uses VARCHAR and not CHAR for Strings. What is the
> complete stack trace (including all root causes)? Could you also post
> the complete Hibernate configuration (including mappings and and Java
> classes if you configure things with annotations)? What version of
> Hibernate do you use?
>
> Regards,
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups "H2 
> Database" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/h2-database?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to