Hibernate:实体内部没有默认构造函数 Class
Hibernate: No default constructor for entity Inner Class
我知道有很多类似的问题,但是 none 在这方面帮助了我。
我正在使用一个名为 Tynamo 的 CRUD 框架,它又依赖于 Apache Tapestry 和 Hibernate。这一切都很好,除了当我尝试将它用于带有 composite/compound 主键的 table 上的 CRUD 时。
我决定不走 @EmbeddedId
路线,因为它似乎根本不适用于该框架。话虽如此,我一直在使用 @IdClass
方法,该方法大部分都有效;我想我离成功还有一两行代码。
问题是,当它开始使用反射来构建对象时,它会爆炸并说,org.hibernate.InstantiationException: No default constructor for entity: ...
,即使确实有一个 public,那个内部的空构造函数class.
回答时,请避免使用代码片段,并使用完整的 classes 等,以便访问此线程的其他人可以更全面地了解正在发生的事情。
你可以在下面看到我的class:
package com.company.crud.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import com.company.crud.entities.TransferExtension.TransferExtensionPK;
@Entity(name = "Transfer_Extensions")
@IdClass(TransferExtensionPK.class)
public class TransferExtension implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// @NotNull(message = "Please supply a Script Code")
// @Length(min = 3, max = 4)
@Column(name = "Division", nullable = false)
private String scriptCode;
@Id
// @NotNull(message = "Please supply a Transfer Type")
// @Length(min = 3, max = 6)
@Column(name = "Transfer_Type", nullable = false)
private String transferType;
@Column(name = "Extension", nullable = true)
private String englishExtension;
@Column(name = "Span_Extension", nullable = true)
private String spanishExtension;
@Column(name = "Call_Type", nullable = true)
private String callType;
@Column(name = "Call_Center", nullable = true)
private String callCenter;
public TransferExtension() {
}
public TransferExtension(String scriptCode, String transferType,
String englishExtension, String spanishExtension, String callType,
String callCenter) {
this.callCenter = callCenter;
this.callType = callType;
this.englishExtension = englishExtension;
this.scriptCode = scriptCode;
this.spanishExtension = spanishExtension;
this.transferType = transferType;
}
public String getScriptCode() {
return this.scriptCode;
}
public void setScriptCode(String scriptCode) {
this.scriptCode = scriptCode;
}
public String getTransferType() {
return this.transferType;
}
public void setTransferType(String transferType) {
this.transferType = transferType;
}
public String getEnglishExtension() {
return this.englishExtension;
}
public void setEnglishExtension(String englishExtension) {
this.englishExtension = englishExtension;
}
public String getSpanishExtension() {
return this.spanishExtension;
}
public void setSpanishExtension(String spanishExtension) {
this.spanishExtension = spanishExtension;
}
public String getCallType() {
return this.callType;
}
public void setCallType(String callType) {
this.callType = callType;
}
public String getCallCenter() {
return this.callCenter;
}
public void setCallCenter(String callCenter) {
this.callCenter = callCenter;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TransferExtension [scriptCode=")
.append(this.scriptCode).append(", transferType=")
.append(this.transferType).append(", englishExtension=")
.append(this.englishExtension).append(", spanishExtension=")
.append(this.spanishExtension).append(", callType=")
.append(this.callType).append(", callCenter=")
.append(this.callCenter).append("]");
return builder.toString();
}
public class TransferExtensionPK implements Serializable {
private static final long serialVersionUID = 4L;
private String scriptCode;
private String transferType;
public TransferExtensionPK() {
}
public TransferExtensionPK(String scriptCode, String transferType) {
this.scriptCode = scriptCode;
this.transferType = transferType;
}
public String getScriptCode() {
return this.scriptCode;
}
public void setScriptCode(String scriptCode) {
this.scriptCode = scriptCode;
}
public String getTransferType() {
return this.transferType;
}
public void setTransferType(String transferType) {
this.transferType = transferType;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TransferExtensionPK [scriptCode=")
.append(this.scriptCode).append(", transferType=")
.append(this.transferType).append("]");
return builder.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType().hashCode();
result = prime
* result
+ ((this.scriptCode == null) ? 0 : this.scriptCode
.hashCode());
result = prime
* result
+ ((this.transferType == null) ? 0 : this.transferType
.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TransferExtensionPK)) {
return false;
}
TransferExtensionPK other = (TransferExtensionPK) obj;
if (!getOuterType().equals(other.getOuterType())) {
return false;
}
if (this.scriptCode == null) {
if (other.scriptCode != null) {
return false;
}
} else if (!this.scriptCode.equals(other.scriptCode)) {
return false;
}
if (this.transferType == null) {
if (other.transferType != null) {
return false;
}
} else if (!this.transferType.equals(other.transferType)) {
return false;
}
return true;
}
private TransferExtension getOuterType() {
return TransferExtension.this;
}
}
}
堆栈跟踪:
Hibernate:
select
count(*) as y0_
from
Transfer_Extensions this_
Hibernate:
select
top 25 this_.Division as Division1_0_,
this_.Transfer_Type as Transfer2_1_0_,
this_.Call_Center as Call3_1_0_,
this_.Call_Type as Call4_1_0_,
this_.Extension as Extension1_0_,
this_.Span_Extension as Span6_1_0_
from
Transfer_Extensions this_
[ERROR] pages.List Render queue error in SetupRender[List:grid]: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
org.apache.tapestry5.ioc.internal.util.TapestryException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK [at context:List.tml, line 12]
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:158)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:186)
at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
at org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_f31f9af2bde.render(Unknown Source)
at $PageRenderQueue_f31f9af2bdd.render(Unknown Source)
at org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1994)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1978)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1960)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1945)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1931)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1913)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1894)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at $MarkupRenderer_f31f9af2bdc.renderMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47)
at $PageMarkupRenderer_f31f9af2bd5.renderPageMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
at $PageResponseRenderer_f31f9af2bd7.advised$renderPageResponse_f31f9af2bd9(Unknown Source)
at $PageResponseRenderer_f31f9af2bd7$Invocation_renderPageResponse_f31f9af2bd8.proceedToAdvisedMethod(Unknown Source)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84)
at org.tynamo.services.TynamoCoreModule.advise(TynamoCoreModule.java:353)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86)
at $PageResponseRenderer_f31f9af2bd7.renderPageResponse(Unknown Source)
at $PageResponseRenderer_f31f9af2bd0.renderPageResponse(Unknown Source)
at org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:64)
at org.apache.tapestry5.services.TapestryModule.handle(TapestryModule.java:2222)
at $PageRenderRequestHandler_f31f9af2bd2.handle(Unknown Source)
at $PageRenderRequestHandler_f31f9af2bcd.handle(Unknown Source)
at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
at org.apache.tapestry5.services.InitializeActivePageName.handlePageRender(InitializeActivePageName.java:47)
at $ComponentRequestHandler_f31f9af2bce.handlePageRender(Unknown Source)
at $ComponentRequestHandler_f31f9af2ac7.handlePageRender(Unknown Source)
at org.tynamo.routing.services.RouterDispatcher.dispatch(RouterDispatcher.java:26)
at $Dispatcher_f31f9af2acb.dispatch(Unknown Source)
at $Dispatcher_f31f9af2ac4.dispatch(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:902)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:892)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:105)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:95)
at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at $RequestHandler_f31f9af2ab9.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
at $HttpServletRequestFilter_f31f9af2ab7.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:852)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2ab5.service(Unknown Source)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.hibernate.InstantiationException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:107)
at org.hibernate.tuple.component.AbstractComponentTuplizer.instantiate(AbstractComponentTuplizer.java:102)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:511)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:517)
at org.hibernate.type.EmbeddedComponentType.instantiate(EmbeddedComponentType.java:59)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:609)
at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:722)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:606)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:349)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:333)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:172)
at $HibernatePersistenceService_f31f9af2bf1.getInstances(Unknown Source)
at $HibernatePersistenceService_f31f9af2b41.getInstances(Unknown Source)
at org.tynamo.TynamoGridDataSource.prepare(TynamoGridDataSource.java:58)
at org.apache.tapestry5.corelib.components.Grid$CachingDataSource.prepare(Grid.java:313)
at org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:483)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:447)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:179)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:148)
... 94 more
[INFO] InternalModule.PageResponseRenderer discarding all List page persistent field changes due to a RenderQueueException
[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: Render queue error in SetupRender[List:grid]: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
org.apache.tapestry5.internal.services.RenderQueueException: Render queue error in SetupRender[List:grid]: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK [at context:List.tml, line 12]
at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:81)
at org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_f31f9af2bde.render(Unknown Source)
at $PageRenderQueue_f31f9af2bdd.render(Unknown Source)
at org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1994)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1978)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1960)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1945)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1931)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1913)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1894)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at $MarkupRenderer_f31f9af2bdc.renderMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47)
at $PageMarkupRenderer_f31f9af2bd5.renderPageMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
at $PageResponseRenderer_f31f9af2bd7.advised$renderPageResponse_f31f9af2bd9(Unknown Source)
at $PageResponseRenderer_f31f9af2bd7$Invocation_renderPageResponse_f31f9af2bd8.proceedToAdvisedMethod(Unknown Source)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84)
at org.tynamo.services.TynamoCoreModule.advise(TynamoCoreModule.java:353)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86)
at $PageResponseRenderer_f31f9af2bd7.renderPageResponse(Unknown Source)
at $PageResponseRenderer_f31f9af2bd0.renderPageResponse(Unknown Source)
at org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:64)
at org.apache.tapestry5.services.TapestryModule.handle(TapestryModule.java:2222)
at $PageRenderRequestHandler_f31f9af2bd2.handle(Unknown Source)
at $PageRenderRequestHandler_f31f9af2bcd.handle(Unknown Source)
at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
at org.apache.tapestry5.services.InitializeActivePageName.handlePageRender(InitializeActivePageName.java:47)
at $ComponentRequestHandler_f31f9af2bce.handlePageRender(Unknown Source)
at $ComponentRequestHandler_f31f9af2ac7.handlePageRender(Unknown Source)
at org.tynamo.routing.services.RouterDispatcher.dispatch(RouterDispatcher.java:26)
at $Dispatcher_f31f9af2acb.dispatch(Unknown Source)
at $Dispatcher_f31f9af2ac4.dispatch(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:902)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:892)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:105)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:95)
at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at $RequestHandler_f31f9af2ab9.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
at $HttpServletRequestFilter_f31f9af2ab7.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:852)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2ab5.service(Unknown Source)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK [at context:List.tml, line 12]
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:158)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:186)
at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
... 92 more
Caused by: org.hibernate.InstantiationException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:107)
at org.hibernate.tuple.component.AbstractComponentTuplizer.instantiate(AbstractComponentTuplizer.java:102)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:511)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:517)
at org.hibernate.type.EmbeddedComponentType.instantiate(EmbeddedComponentType.java:59)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:609)
at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:722)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:606)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:349)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:333)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:172)
at $HibernatePersistenceService_f31f9af2bf1.getInstances(Unknown Source)
at $HibernatePersistenceService_f31f9af2b41.getInstances(Unknown Source)
at org.tynamo.TynamoGridDataSource.prepare(TynamoGridDataSource.java:58)
at org.apache.tapestry5.corelib.components.Grid$CachingDataSource.prepare(Grid.java:313)
at org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:483)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:447)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:179)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:148)
... 94 more
在幕后,TransferExtensionPK
实际上没有默认构造函数,因为它是一个内部 class。内部 classes 需要外部 class 的实例才能构造,因此编译器已将您的无参数构造函数转换为接受 TransferExtension
实例的单参数构造函数.
要解决此问题,请将 TransferExtensionPK
设为嵌套 class(静态)而不是内部 class:
public static class TransferExtensionPK // etc
我知道有很多类似的问题,但是 none 在这方面帮助了我。
我正在使用一个名为 Tynamo 的 CRUD 框架,它又依赖于 Apache Tapestry 和 Hibernate。这一切都很好,除了当我尝试将它用于带有 composite/compound 主键的 table 上的 CRUD 时。
我决定不走 @EmbeddedId
路线,因为它似乎根本不适用于该框架。话虽如此,我一直在使用 @IdClass
方法,该方法大部分都有效;我想我离成功还有一两行代码。
问题是,当它开始使用反射来构建对象时,它会爆炸并说,org.hibernate.InstantiationException: No default constructor for entity: ...
,即使确实有一个 public,那个内部的空构造函数class.
回答时,请避免使用代码片段,并使用完整的 classes 等,以便访问此线程的其他人可以更全面地了解正在发生的事情。
你可以在下面看到我的class:
package com.company.crud.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import com.company.crud.entities.TransferExtension.TransferExtensionPK;
@Entity(name = "Transfer_Extensions")
@IdClass(TransferExtensionPK.class)
public class TransferExtension implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// @NotNull(message = "Please supply a Script Code")
// @Length(min = 3, max = 4)
@Column(name = "Division", nullable = false)
private String scriptCode;
@Id
// @NotNull(message = "Please supply a Transfer Type")
// @Length(min = 3, max = 6)
@Column(name = "Transfer_Type", nullable = false)
private String transferType;
@Column(name = "Extension", nullable = true)
private String englishExtension;
@Column(name = "Span_Extension", nullable = true)
private String spanishExtension;
@Column(name = "Call_Type", nullable = true)
private String callType;
@Column(name = "Call_Center", nullable = true)
private String callCenter;
public TransferExtension() {
}
public TransferExtension(String scriptCode, String transferType,
String englishExtension, String spanishExtension, String callType,
String callCenter) {
this.callCenter = callCenter;
this.callType = callType;
this.englishExtension = englishExtension;
this.scriptCode = scriptCode;
this.spanishExtension = spanishExtension;
this.transferType = transferType;
}
public String getScriptCode() {
return this.scriptCode;
}
public void setScriptCode(String scriptCode) {
this.scriptCode = scriptCode;
}
public String getTransferType() {
return this.transferType;
}
public void setTransferType(String transferType) {
this.transferType = transferType;
}
public String getEnglishExtension() {
return this.englishExtension;
}
public void setEnglishExtension(String englishExtension) {
this.englishExtension = englishExtension;
}
public String getSpanishExtension() {
return this.spanishExtension;
}
public void setSpanishExtension(String spanishExtension) {
this.spanishExtension = spanishExtension;
}
public String getCallType() {
return this.callType;
}
public void setCallType(String callType) {
this.callType = callType;
}
public String getCallCenter() {
return this.callCenter;
}
public void setCallCenter(String callCenter) {
this.callCenter = callCenter;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TransferExtension [scriptCode=")
.append(this.scriptCode).append(", transferType=")
.append(this.transferType).append(", englishExtension=")
.append(this.englishExtension).append(", spanishExtension=")
.append(this.spanishExtension).append(", callType=")
.append(this.callType).append(", callCenter=")
.append(this.callCenter).append("]");
return builder.toString();
}
public class TransferExtensionPK implements Serializable {
private static final long serialVersionUID = 4L;
private String scriptCode;
private String transferType;
public TransferExtensionPK() {
}
public TransferExtensionPK(String scriptCode, String transferType) {
this.scriptCode = scriptCode;
this.transferType = transferType;
}
public String getScriptCode() {
return this.scriptCode;
}
public void setScriptCode(String scriptCode) {
this.scriptCode = scriptCode;
}
public String getTransferType() {
return this.transferType;
}
public void setTransferType(String transferType) {
this.transferType = transferType;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("TransferExtensionPK [scriptCode=")
.append(this.scriptCode).append(", transferType=")
.append(this.transferType).append("]");
return builder.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType().hashCode();
result = prime
* result
+ ((this.scriptCode == null) ? 0 : this.scriptCode
.hashCode());
result = prime
* result
+ ((this.transferType == null) ? 0 : this.transferType
.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TransferExtensionPK)) {
return false;
}
TransferExtensionPK other = (TransferExtensionPK) obj;
if (!getOuterType().equals(other.getOuterType())) {
return false;
}
if (this.scriptCode == null) {
if (other.scriptCode != null) {
return false;
}
} else if (!this.scriptCode.equals(other.scriptCode)) {
return false;
}
if (this.transferType == null) {
if (other.transferType != null) {
return false;
}
} else if (!this.transferType.equals(other.transferType)) {
return false;
}
return true;
}
private TransferExtension getOuterType() {
return TransferExtension.this;
}
}
}
堆栈跟踪:
Hibernate:
select
count(*) as y0_
from
Transfer_Extensions this_
Hibernate:
select
top 25 this_.Division as Division1_0_,
this_.Transfer_Type as Transfer2_1_0_,
this_.Call_Center as Call3_1_0_,
this_.Call_Type as Call4_1_0_,
this_.Extension as Extension1_0_,
this_.Span_Extension as Span6_1_0_
from
Transfer_Extensions this_
[ERROR] pages.List Render queue error in SetupRender[List:grid]: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
org.apache.tapestry5.ioc.internal.util.TapestryException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK [at context:List.tml, line 12]
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:158)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:186)
at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
at org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_f31f9af2bde.render(Unknown Source)
at $PageRenderQueue_f31f9af2bdd.render(Unknown Source)
at org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1994)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1978)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1960)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1945)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1931)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1913)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1894)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at $MarkupRenderer_f31f9af2bdc.renderMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47)
at $PageMarkupRenderer_f31f9af2bd5.renderPageMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
at $PageResponseRenderer_f31f9af2bd7.advised$renderPageResponse_f31f9af2bd9(Unknown Source)
at $PageResponseRenderer_f31f9af2bd7$Invocation_renderPageResponse_f31f9af2bd8.proceedToAdvisedMethod(Unknown Source)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84)
at org.tynamo.services.TynamoCoreModule.advise(TynamoCoreModule.java:353)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86)
at $PageResponseRenderer_f31f9af2bd7.renderPageResponse(Unknown Source)
at $PageResponseRenderer_f31f9af2bd0.renderPageResponse(Unknown Source)
at org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:64)
at org.apache.tapestry5.services.TapestryModule.handle(TapestryModule.java:2222)
at $PageRenderRequestHandler_f31f9af2bd2.handle(Unknown Source)
at $PageRenderRequestHandler_f31f9af2bcd.handle(Unknown Source)
at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
at org.apache.tapestry5.services.InitializeActivePageName.handlePageRender(InitializeActivePageName.java:47)
at $ComponentRequestHandler_f31f9af2bce.handlePageRender(Unknown Source)
at $ComponentRequestHandler_f31f9af2ac7.handlePageRender(Unknown Source)
at org.tynamo.routing.services.RouterDispatcher.dispatch(RouterDispatcher.java:26)
at $Dispatcher_f31f9af2acb.dispatch(Unknown Source)
at $Dispatcher_f31f9af2ac4.dispatch(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:902)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:892)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:105)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:95)
at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at $RequestHandler_f31f9af2ab9.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
at $HttpServletRequestFilter_f31f9af2ab7.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:852)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2ab5.service(Unknown Source)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.hibernate.InstantiationException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:107)
at org.hibernate.tuple.component.AbstractComponentTuplizer.instantiate(AbstractComponentTuplizer.java:102)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:511)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:517)
at org.hibernate.type.EmbeddedComponentType.instantiate(EmbeddedComponentType.java:59)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:609)
at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:722)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:606)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:349)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:333)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:172)
at $HibernatePersistenceService_f31f9af2bf1.getInstances(Unknown Source)
at $HibernatePersistenceService_f31f9af2b41.getInstances(Unknown Source)
at org.tynamo.TynamoGridDataSource.prepare(TynamoGridDataSource.java:58)
at org.apache.tapestry5.corelib.components.Grid$CachingDataSource.prepare(Grid.java:313)
at org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:483)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:447)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:179)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:148)
... 94 more
[INFO] InternalModule.PageResponseRenderer discarding all List page persistent field changes due to a RenderQueueException
[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: Render queue error in SetupRender[List:grid]: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
org.apache.tapestry5.internal.services.RenderQueueException: Render queue error in SetupRender[List:grid]: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK [at context:List.tml, line 12]
at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:81)
at org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_f31f9af2bde.render(Unknown Source)
at $PageRenderQueue_f31f9af2bdd.render(Unknown Source)
at org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1994)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1978)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1960)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1945)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1931)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1913)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:1894)
at $MarkupRenderer_f31f9af2be1.renderMarkup(Unknown Source)
at $MarkupRenderer_f31f9af2bdc.renderMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47)
at $PageMarkupRenderer_f31f9af2bd5.renderPageMarkup(Unknown Source)
at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
at $PageResponseRenderer_f31f9af2bd7.advised$renderPageResponse_f31f9af2bd9(Unknown Source)
at $PageResponseRenderer_f31f9af2bd7$Invocation_renderPageResponse_f31f9af2bd8.proceedToAdvisedMethod(Unknown Source)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84)
at org.tynamo.services.TynamoCoreModule.advise(TynamoCoreModule.java:353)
at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86)
at $PageResponseRenderer_f31f9af2bd7.renderPageResponse(Unknown Source)
at $PageResponseRenderer_f31f9af2bd0.renderPageResponse(Unknown Source)
at org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:64)
at org.apache.tapestry5.services.TapestryModule.handle(TapestryModule.java:2222)
at $PageRenderRequestHandler_f31f9af2bd2.handle(Unknown Source)
at $PageRenderRequestHandler_f31f9af2bcd.handle(Unknown Source)
at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
at org.apache.tapestry5.services.InitializeActivePageName.handlePageRender(InitializeActivePageName.java:47)
at $ComponentRequestHandler_f31f9af2bce.handlePageRender(Unknown Source)
at $ComponentRequestHandler_f31f9af2ac7.handlePageRender(Unknown Source)
at org.tynamo.routing.services.RouterDispatcher.dispatch(RouterDispatcher.java:26)
at $Dispatcher_f31f9af2acb.dispatch(Unknown Source)
at $Dispatcher_f31f9af2ac4.dispatch(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:902)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:892)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:105)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.invoke(CheckForUpdatesFilter.java:95)
at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
at $RequestHandler_f31f9af2ac5.service(Unknown Source)
at $RequestHandler_f31f9af2ab9.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
at $HttpServletRequestFilter_f31f9af2ab7.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule.service(TapestryModule.java:852)
at $HttpServletRequestHandler_f31f9af2abb.service(Unknown Source)
at $HttpServletRequestHandler_f31f9af2ab5.service(Unknown Source)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK [at context:List.tml, line 12]
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:158)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:186)
at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
... 92 more
Caused by: org.hibernate.InstantiationException: No default constructor for entity: com.company.crud.entities.TransferExtension$TransferExtensionPK
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:107)
at org.hibernate.tuple.component.AbstractComponentTuplizer.instantiate(AbstractComponentTuplizer.java:102)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:511)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:517)
at org.hibernate.type.EmbeddedComponentType.instantiate(EmbeddedComponentType.java:59)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:609)
at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:722)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:606)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:349)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:333)
at org.tynamo.hibernate.services.HibernatePersistenceServiceImpl.getInstances(HibernatePersistenceServiceImpl.java:172)
at $HibernatePersistenceService_f31f9af2bf1.getInstances(Unknown Source)
at $HibernatePersistenceService_f31f9af2b41.getInstances(Unknown Source)
at org.tynamo.TynamoGridDataSource.prepare(TynamoGridDataSource.java:58)
at org.apache.tapestry5.corelib.components.Grid$CachingDataSource.prepare(Grid.java:313)
at org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:483)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:447)
at org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:179)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:148)
... 94 more
在幕后,TransferExtensionPK
实际上没有默认构造函数,因为它是一个内部 class。内部 classes 需要外部 class 的实例才能构造,因此编译器已将您的无参数构造函数转换为接受 TransferExtension
实例的单参数构造函数.
要解决此问题,请将 TransferExtensionPK
设为嵌套 class(静态)而不是内部 class:
public static class TransferExtensionPK // etc