org.hibernate.PropertyNotFoundException:找不到getter

时间:2015-05-19 07:34:49

标签: java hibernate gwt

我的应用程序基于GWT,java,hibernate

我喜欢上课

 public class Test implements Serializable {
     private long id;
     private String companyName;

     public long getId() {
          return id;
     }
     public void setId(long id) {
         this.id = id;
     }
     public String getCompanyName() {
         return companyName;
     }
     public void setCompanyName(String companyName) {
         this.companyName = companyName;
     }
 }

下面是我的hbm文件

Test.hbm.xml:

  <property name="id" column="id" type="long"/>
  <property name="companyName" column="company_name" type="string"/>

当我尝试调试我的应用程序时,它会抛出错误。

org.hibernate.PropertyNotFoundException: Could not find a getter for companyName in class Test
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.mapping.Property.getGetter(Property.java:272)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
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:1294)

它在一次应用中工作正常,并在其他应用程序中出错。

有人可以帮忙解决这个例外吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试清理项目,重建并重新部署它。也许没有考虑到一些变化。