hibernate中sessionfactory 无法创建!!!

sj307639429 2010-01-22 03:26:46
tomcat报错:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/F:/java%20projects/.metadata/.plugins/org.eclipse.wst.server.core/tmp4/wtpwebapps/coochong/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:118)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

applicationContext.xml中相关内容如下:
<property name="mappingResources">
<list>
<value>com/bjw/coochong/bean/Address.hbm.xml</value>
<value>com/bjw/coochong/bean/Album.hbm.xml</value>
<value>com/bjw/coochong/bean/Customer.hbm.xml</value>
<value>com/bjw/coochong/bean/AlbumPhoto.hbm.xml</value>
<value>com/bjw/coochong/bean/MembershipPoint.hbm.xml</value>
<value>com/bjw/coochong/bean/Coupon.hbm.xml</value>
<value>com/bjw/coochong/bean/Order.hbm.xml</value>
<value>com/bjw/coochong/bean/Category.hbm.xml</value>
<value>com/bjw/coochong/bean/Product.hbm.xml</value>
<value>com/bjw/coochong/bean/Photo.hbm.xml</value>
<value>com/bjw/coochong/bean/Item.hbm.xml</value>
<value>com/bjw/coochong/bean/CouponCard.hbm.xml</value>
<value>com/bjw/coochong/bean/Gift.hbm.xml</value>
<value>com/bjw/coochong/bean/AllAddress.hbm.xml</value>

<!-这就是要映射的bean->
<value>com/bjw/coochong/bean/RechargeableCard.hbm.xml</value>

<value>com/bjw/coochong/bean/AccountDetail.hbm.xml</value>
<value>com/bjw/coochong/bean/Account.hbm.xml</value>
<value>com/bjw/coochong/bean/RealAlbum.hbm.xml</value>
<value>com/bjw/coochong/bean/RealAlbumCategory.hbm.xml</value>
<value>com/bjw/coochong/bean/RealAlbumSeries.hbm.xml</value>
<value>com/bjw/coochong/bean/RealAlbumSeriesCategory.hbm.xml</value>
<value>com/bjw/coochong/bean/UserMessage1.hbm.xml</value>
<value>com/bjw/coochong/bean/CnsfeOrder.hbm.xml</value>
</list>

对应的RechargeableCard.hbm.xml内容如下:
<class name="RechargeableCard" table="RechargeableCard">
<id name="id" column="id" type="java.lang.Integer">
<generator class="increment" />
</id>

RechargeableCard.java 中id有public的geter方法
这就奇怪了,大家帮下忙啊
...全文
252 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zl3450341 2010-01-22
  • 打赏
  • 举报
回复
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard ]
错误提示是这个啊
sj307639429 2010-01-22
  • 打赏
  • 举报
回复
我再顶!!
sj307639429 2010-01-22
  • 打赏
  • 举报
回复
id是integer类型的
xlxyeyu 2010-01-22
  • 打赏
  • 举报
回复
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard

粗心造成的,这个bean里面的id 的getter没有设置!
sj307639429 2010-01-22
  • 打赏
  • 举报
回复
自己再顶下,另外,我用的hibernate是3.4,这个项目的代码以前是好像是在3.0下写的,这个有影响不,3.4应该兼容3.0吧
zx27600 2010-01-22
  • 打赏
  • 举报
回复
你的id是字符串类型的吧,如果是,<generator class="increment" /> 这怎么可以,应该用<generator class="Uuid.hex" />

ljjining 2010-01-22
  • 打赏
  • 举报
回复
重新生成吧
sj307639429 2010-01-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 fantasy2436 的回复:]
是不是你ID的生成策略有問題?
[/Quote]
生成策略是
<generator class="increment" />

应该没问题吧
sj307639429 2010-01-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 licip 的回复:]
exception is org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard
这个类:com.bjw.coochong.bean.RechargeableCard 是你自己写的吧.
里面是不是有个id的属性,你没有给它写get方法是不是.你自己检查一下.
[/Quote]

这个类里肯定有id,id也有getter的。
fantasy2436 2010-01-22
  • 打赏
  • 举报
回复
是不是你ID的生成策略有問題?
道光2008 2010-01-22
  • 打赏
  • 举报
回复
Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard ?
RechargeableCard 没有设置id的get方法
licip 2010-01-22
  • 打赏
  • 举报
回复
exception is org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.bjw.coochong.bean.RechargeableCard
这个类:com.bjw.coochong.bean.RechargeableCard 是你自己写的吧.
里面是不是有个id的属性,你没有给它写get方法是不是.你自己检查一下.

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧