尝试使用 County 扩展 Unit 时发生错误,特别是在重新启动应用程序以初始化 ORM 时。[注意:我正在尝试单表继承]
ORM 正在管理我的数据库模式:this.ormsettings.dbcreate=dropcreate
当我从模型目录中删除 County.cfc 时,ORM 初始化并且应用程序正常启动。当我将 County.cfc 放回模型目录时,错误再次出现。
ColdFusion 版本 10,282462 MSSQL IIS
单元:
<cfcomponent persistent="true" entityname="Unit" table="Units" discriminatorColumn="type">
<cfproperty name="id" fieldtype="id" column="unit_id" generator="identity">
<cfproperty name="name" default="" type="string" length="50">
<cfproperty name="description" type="string" sqltype="varchar(max)" default="">
<cfproperty name="active" type="boolean" default="true">
</cfcomponent>
县:
<cfcomponent persistent="true" entityname="County" table="Units" extends="Unit" discriminatorValue="county">
<cfproperty name="officeAddress" type="string">
</cfcomponent>
堆栈跟踪:
java.lang.NullPointerException at
org.hibernate.mapping.PersistentClass.createPrimaryKey(PersistentClass.java:322) at
org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:405) at
org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:321) at
org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:172) at
org.hibernate.cfg.Configuration.add(Configuration.java:771) at
org.hibernate.cfg.Configuration.addDocument(Configuration.java:586) at
coldfusion.orm.hibernate.HibernateConfiguration.buildConfiguration(HibernateConfiguration.java:611) at
coldfusion.orm.hibernate.HibernateConfiguration.initHibernateConfiguration(HibernateConfiguration.java:208) at
coldfusion.orm.hibernate.HibernateConfiguration.<init>(HibernateConfiguration.java:181) at
coldfusion.orm.hibernate.ConfigurationManager.initConfiguration(ConfigurationManager.java:67) at
coldfusion.orm.hibernate.HibernateProvider.InitializeORMForApplication(HibernateProvider.java:185) at
coldfusion.orm.hibernate.HibernateProvider.onPageRequestStart(HibernateProvider.java:151) at
coldfusion.filter.ApplicationFilter.firePageRequestStart(ApplicationFilter.java:599) at
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:407) at
coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at
coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at
coldfusion.filter.PathFilter.invoke(PathFilter.java:112) at
coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at
coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79) at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at
coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at
coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at
coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at
coldfusion.CfmServlet.service(CfmServlet.java:204) at
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414) at
org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:203) at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at
java.lang.Thread.run(Thread.java:662)
奇怪的是,我已经在与另一个实体做类似的事情(DiscussionPost 扩展了 Post):
邮政:
<cfcomponent persistent="true" entityname="Post" table="Posts" discriminatorColumn="type">
<cfproperty name="id" fieldtype="id" column="post_id" generator="identity">
<cfproperty name="promotions" fieldtype="one-to-many" cfc="PostPromotion" fkcolumn="post_id" singularname="promotion">
<cfproperty name="comments" fieldtype="one-to-many" cfc="PostComment" fkcolumn="post_id" singularname="comment">
<cfproperty name="user" fieldtype="many-to-one" cfc="User" fkcolumn="user_id">
<cfproperty name="text" type="string" sqltype="varchar(1000)">
<cfproperty name="timestamp" type="date" ormtype="timestamp">
</cfcomponent>
讨论帖:
<cfcomponent persistent="true" entityname="DiscussionPost" table="Posts" extends="Post" discriminatorValue="discussionpost">
<cfproperty name="discussion" fieldtype="many-to-one" cfc="Discussion" fkcolumn="discussion_id">
<cfproperty name="title" type="string" sqltype="varchar(200)">
</cfcomponent>
我错过了什么?