首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

hibernate和ACCESS连接出现的有关问题

2012-08-01 
hibernate和ACCESS连接出现的问题直接对单个实体类进行查询可以,碰到含有一对多等关系时候,set集合无法查

hibernate和ACCESS连接出现的问题
直接对单个实体类进行查询可以,碰到含有一对多等关系时候,set集合无法查询出来
Hibernate: select informatio0_.INFOID as INFOID0_, informatio0_.NAME as NAME0_ from INFORMATION informatio0_
Hibernate: select attributes0_.INFOID as INFOID1_, attributes0_.ATT_ID as ATT1_1_, attributes0_.ATT_ID as ATT1_2_0_, attributes0_.INFOID as INFOID2_0_, attributes0_.ATT_NAME as ATT3_2_0_, attributes0_.ATT_CONTEXT as ATT4_2_0_, attributes0_.ISCHLID as ISCHLID2_0_, attributes0_.ATT_TUPIAN as ATT6_2_0_ from ATTRIBUTE attributes0_ where attributes0_.INFOID=?
下面是错误信息
org.hibernate.exception.GenericJDBCException: could not initialize a collection: [com.entity.Information.attributes#3]
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:132)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:120)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.loader.Loader.loadCollection(Loader.java:2043)
org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:62)
org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:628)
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1853)
org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:890)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:276)
org.hibernate.loader.Loader.doList(Loader.java:2249)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2146)
org.hibernate.loader.Loader.list(Loader.java:2141)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:416)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
com.action.dbwj.FileUploadAction.execute(FileUploadAction.java:64)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)


com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:306)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)


root cause 

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]可选的功能未实现
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterBigint(JdbcOdbc.java:1224)
sun.jdbc.odbc.JdbcOdbcPreparedStatement.setLong(JdbcOdbcPreparedStatement.java:594)
org.hibernate.type.LongType.set(LongType.java:65)
org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1747)
org.hibernate.loader.Loader.bindParameterValues(Loader.java:1718)


org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1608)
org.hibernate.loader.Loader.doQuery(Loader.java:713)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:271)
org.hibernate.loader.Loader.loadCollection(Loader.java:2036)
org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:62)
org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:628)
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1853)
org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:890)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:276)
org.hibernate.loader.Loader.doList(Loader.java:2249)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2146)
org.hibernate.loader.Loader.list(Loader.java:2141)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:416)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
com.action.dbwj.FileUploadAction.execute(FileUploadAction.java:64)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
以下打不下省略了

[解决办法]
org.hibernate.exception.GenericJDBCException: could not initialize a collection: 
拒绝连接,应该是驱动不对。。你好好看看,我想问下你用ACCESSS做什么。。。。。
[解决办法]
是你的这个驱动不支持hibernate的延迟加载功能。 你要么换个驱动,要么在hibernate配置文件里面把lazy改为false

热点排行