2 newbie programmer Newbie_Programmer 于 2015.07.04 22:45 提问

刚刚学习hibernate,出了点错,大神能帮我看看吗?

org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer]
at org.hibernate.tuple.component.ComponentTuplizerFactory.constructTuplizer(ComponentTuplizerFactory.java:101)
at org.hibernate.tuple.component.ComponentTuplizerFactory.constructDefaultTuplizer(ComponentTuplizerFactory.java:122)
at org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.(ComponentEntityModeToTuplizerMapping.java:75)
at org.hibernate.tuple.component.ComponentMetamodel.(ComponentMetamodel.java:73)
at org.hibernate.mapping.Component.buildType(Component.java:175)
at org.hibernate.mapping.Component.getType(Component.java:168)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
at org.hibernate.mapping.RootClass.validate(RootClass.java:216)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
at com.sxt.dao.HibernateSessionFactory.(HibernateSessionFactory.java:31)
at com.sxt.dao.impl.UserLoginDaoImpl.findUsersByName(UserLoginDaoImpl.java:12)
at com.sxt.Biz.impl.UserLoginBizImpl.findUsers(UserLoginBizImpl.java:12)
at com.sxt.web.action.UserLoginAction.userLogin(UserLoginAction.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

5个回答

devmiao
devmiao   Ds   Rxr 2015.07.04 23:29
Newbie_Programmer
Newbie_Programmer 谢谢了,那个是我的方法错了,中间表是不需要反转的,麻烦了
2 年多之前 回复
Newbie_Programmer
Newbie_Programmer   2015.07.04 22:51

Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.hibernate.tuple.component.ComponentTuplizerFactory.constructTuplizer(ComponentTuplizerFactory.java:98)
... 78 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for role in class com.sxt.entity.RoleMenuId
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
at org.hibernate.tuple.component.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:156)
at org.hibernate.tuple.component.AbstractComponentTuplizer.(AbstractComponentTuplizer.java:66)
at org.hibernate.tuple.component.PojoComponentTuplizer.(PojoComponentTuplizer.java:61)
... 83 more
%%%% Error Creating SessionFactory %%%%

Newbie_Programmer
Newbie_Programmer   2015.07.04 22:51

%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/sxt/entity/Menu.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:616)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
at com.sxt.dao.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at com.sxt.dao.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at com.sxt.dao.impl.UserLoginDaoImpl.findUsersByName(UserLoginDaoImpl.java:12)
at com.sxt.Biz.impl.UserLoginBizImpl.findUsers(UserLoginBizImpl.java:12)
at com.sxt.web.action.UserLoginAction.userLogin(UserLoginAction.java:20)
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:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
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:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.sxt.entity.Menu.roleMenu
at org.hibernate.cfg.Mappings.addCollection(Mappings.java:147)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2085)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2060)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:381)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
... 75 more

miracle_yao
miracle_yao   2015.07.04 22:55

Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for role in class com.sxt.entity.RoleMenuId,是没写get/set方法吗?

Newbie_Programmer
Newbie_Programmer 谢谢了,那个是我的方法错了,中间表是不需要反转的,麻烦了
2 年多之前 回复
Newbie_Programmer
Newbie_Programmer 所以就不知怎么写了
2 年多之前 回复
Newbie_Programmer
Newbie_Programmer d表不知道怎么回事
2 年多之前 回复
Newbie_Programmer
Newbie_Programmer 是这样的,我有三个表,一个角色表,一个菜单表,一个关联他们两个的中间表,在使用hibernate自动反转时,生成了四个实体类,其他都对应了oracle数据库的表,但是roleMune
2 年多之前 回复
guwei4037
guwei4037   Ds   Rxr 2015.07.04 23:02

尝试下这些:
http://blog.csdn.net/kezhongke/article/details/23328189
http://www.cnblogs.com/devilfree/archive/2012/11/09/2762290.html

Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for role in class com.sxt.entity.RoleMenuId

看下com.sxt.entity.RoleMenuId这个类的role有没有getter方法。

Newbie_Programmer
Newbie_Programmer 谢谢了,那个是我的方法错了,中间表是不需要反转的,麻烦了
2 年多之前 回复
guwei4037
guwei4037 回复Newbie_Programmer: 中间表就是一张表。你看看:http://blog.csdn.net/xrt95050/article/details/7322222http://lavasoft.blog.51cto.com/62575/39344/再看看我写的NHibernate示例,http://blog.csdn.net/chinacsharper/article/details/19245537大同小异。
2 年多之前 回复
Newbie_Programmer
Newbie_Programmer 恩 谢谢 请你再看一下上楼我的恢复
2 年多之前 回复
guwei4037
guwei4037 http://www.cnblogs.com/yayagepei/articles/1875616.html
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片