0

实际上,我使用 spring mvc 3 和 hibernate 3.5 以及 extjs 作为用户界面来开发 Java Web 应用程序;我的问题是,当我的模型类具有像这样的 BigDecimal 属性时

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonAutoDetect;

@JsonAutoDetect
@Entity
@Table(name="Articles")
public class Article {

@Id
@GeneratedValue
@Column(name="IDARTICLE")
private int id;

@Column(name="CODE")
private String code;

@Column(name="DESIGNATION")
private String designation;

@Column(name="PRIX", scale = 19, precision = 4, columnDefinition = "DECIMAL(19,4)")
private BigDecimal prix; 

@Column(name="CPTARTICLE")
private int cptarticle;

@Column(name="IDPARCOM")
private int idparcom;


public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getCode() {
    return code;
}
public void setCode(String code) {
    this.code = code;
}
public String getDesignation() {
    return designation;
}
public void setDesignation(String designation) {
    this.designation = designation;
}
public BigDecimal getPrix() {
    return prix;
}
public void setPrix(BigDecimal prix) {
    this.prix = prix;
}
public int getCptarticle() {
    return cptarticle;
}
public void setCptarticle(int cptArticle) {
    this.cptarticle = cptArticle;
}
public int getIdparcom() {
    return idparcom;
    }
         public void setIdparcom(int idParcom) {
            this.idparcom = idParcom;
        }
}

当我这样做的时候

List<Article> articles = hibernateTemplate.find("from Articles");

我有 execption 并且在 cosole 中什么都没有,只是这个 Stacks 痕迹

Daemon Thread [http-bio-8080-exec-50] (Suspended)   
ArticleService$$FastClassByCGLIB$$1bae6fb8.invoke(int, Object, Object[]) line: not available    
MethodProxy.invoke(Object, Object[]) line: 191  
Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint() line: 692    
Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 150    
TransactionInterceptor.invoke(MethodInvocation) line: 108   
Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 172    
Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 625 
ArticleService$$EnhancerByCGLIB$$f2eb83ca.getArticleList() line: not available  
ArticleController.read() line: 25   
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available   
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available   
Method.invoke(Object, Object...) line: not available    
AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker(HandlerMethodInvoker).invokeHandlerMethod(Method, Object, NativeWebRequest, ExtendedModelMap) line: 174  
AnnotationMethodHandlerAdapter.invokeHandlerMethod(HttpServletRequest, HttpServletResponse, Object) line: 421   
AnnotationMethodHandlerAdapter.handle(HttpServletRequest, HttpServletResponse, Object) line: 409    
DispatcherServlet.doDispatch(HttpServletRequest, HttpServletResponse) line: 771 
DispatcherServlet.doService(HttpServletRequest, HttpServletResponse) line: 716  
DispatcherServlet(FrameworkServlet).processRequest(HttpServletRequest, HttpServletResponse) line: 644   
DispatcherServlet(FrameworkServlet).doGet(HttpServletRequest, HttpServletResponse) line: 549    
DispatcherServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 621   
DispatcherServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 722   
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 305  
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210  
StandardWrapperValve.invoke(Request, Response) line: 224    
StandardContextValve.invoke(Request, Response) line: 169    
NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 472    
StandardHostValve.invoke(Request, Response) line: 168   
ErrorReportValve.invoke(Request, Response) line: 98 
AccessLogValve.invoke(Request, Response) line: 927  
StandardEngineValve.invoke(Request, Response) line: 118 
CoyoteAdapter.service(Request, Response) line: 407  
Http11Processor(AbstractHttp11Processor<S>).process(SocketWrapper<S>) line: 987 
Http11Protocol$Http11ConnectionHandler(AbstractProtocol$AbstractConnectionHandler<S,P>).process(SocketWrapper<S>, SocketStatus) line: 579   
JIoEndpoint$SocketProcessor.run() line: 309 
ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available 
ThreadPoolExecutor$Worker.run() line: not available 
TaskThread(Thread).run() line: not available    

有人能帮帮我吗

4

1 回答 1

0

这是一个愚蠢的错误,我必须做 List article = hibernateTemplate.find("from Article"); 没有 s 的文章,因为这是类的名称 :-) 不是表的名称。

于 2012-10-05T12:20:08.173 回答