2012-04-05 12 views
0

クラスEventとクラスHazardSubmissionの2つのクラスがあり、クラスはEventです。Hibernateは、スーパークラスではなくサブクラスでプロパティのセッターを誤って探していますか?

クラスEventは、dateCreatedgetDateCreated()、およびsetDateCreated(String)のプロパティを持ちます。

私は試してみてください。

HazardSubmission hs = new HazardSubmission(); 
hs.setDateCreated("A"); 

私はそれがクラスEventでセッターを呼び出すと仮定したが、そのクラスHazardSubmissio n個でセッターを探して!

ここにエラーがありますが、何か助けていただければ幸いです!私のマッピングXMLの:)

SEVERE: Servlet.service() for servlet DispatcherServlet threw exception 
org.hibernate.PropertyNotFoundException: Could not find a setter for property dateCreated in class nz.co.company.healthsafety.stripes.model.HazardSubmission 
    at org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:240) 
    at org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:233) 
    at org.hibernate.mapping.Property.getSetter(Property.java:299) 
    at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertySetter(PojoEntityTuplizer.java:307) 
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:142) 
    at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78) 
    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.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107) 
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135) 
    at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80) 
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323) 
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:456) 
    at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:113) 
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:87) 
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341) 
    at nz.co.company.healthsafety.stripes.action.BaseController.<clinit>(BaseController.java:36) 
    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 java.lang.Class.newInstance0(Class.java:355) 
    at java.lang.Class.newInstance(Class.java:308) 
    at net.sourceforge.stripes.controller.AnnotatedClassActionResolver.makeNewActionBean(AnnotatedClassActionResolver.java:432) 
    at net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:360) 
    at net.sourceforge.stripes.controller.NameBasedActionResolver.getActionBean(NameBasedActionResolver.java:264) 
    at net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:293) 
    at net.sourceforge.stripes.controller.DispatcherHelper$1.intercept(DispatcherHelper.java:106) 
    at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158) 
    at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113) 
    at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155) 
    at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74) 
    at net.sourceforge.stripes.controller.DispatcherHelper.resolveActionBean(DispatcherHelper.java:102) 
    at net.sourceforge.stripes.controller.DispatcherServlet.resolveActionBean(DispatcherServlet.java:238) 
    at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:141) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247) 
    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:230) 
    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:104) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 
    at java.lang.Thread.run(Thread.java:619) 
5/04/2012 4:34:42 PM net.sourceforge.stripes.util.Log warn 

簡素化:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping> 
    <class name="nz.co.company.healthsafety.stripes.model.Event" table="events"> 
     <id name="id" type="java.lang.Integer" column="id"> 
      <generator class="native" /> 
     </id> 
     <property name="dateCreated" column="dateCreated" type="timestamp" not-null="true" length="200" /> 

     <joined-subclass name="nz.co.company.healthsafety.stripes.model.HazardSubmission" table="hazard_submissions"> 
      <key column="id" /> 
      <property name="reporterFirstName" column="reporterFirstName" type="java.lang.String" not-null="true" length="200" /> 
      <property name="reporterLastName" column="reporterLastName" type="java.lang.String" not-null="true" length="200" /> 

     </joined-subclass> 

    </class> 
</hibernate-mapping> 
+0

2つのBeanクラスのソースを添付できますか? – dash1e

+0

Eventクラスのsetterを手動で呼び出したいのはなぜですか? 'HazardSubmission'の役割は何ですか? – Ved

答えて

2

作成日は、あなたのXMLに応じてタイムスタンプでなければなりませんが、あなたがStringとしてプロパティを宣言した表示されます。

これらのタイプのいずれかを変更して一致させることはできますか?

関連する問題