我正在尝试从MerchantTerminalConfig获取数据。当我执行方法获取colimn 3上的错误时,列'3'中的'5.677755704167E12'超出数据类型INTEGER的有效范围。根据查询,第3列是商店ID,在模型类::
中声明为字符串Dao方法代码:
public List<MerchantTerminalConfig> getMerchatStoreTerminalList(int userId,
String storeId) {
Session session = HibernateUtil.getSessionFactory().openSession();
List<MerchantTerminalConfig> merchantStoreTerminalList=new ArrayList();
try{
Criteria criteria=session.createCriteria(MerchantTerminalConfig.class);
#### Fetching result set ##### merchantStoreTerminalList=criteria.add(Restrictions.eq("merchantId",userId)).add(Restrictions.eq("storeId",storeId)).list();
}
catch(Exception e){
e.printStackTrace();
}
return merchantStoreTerminalList;
}
Model类是:
package com.mtaka.finsol.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name="merchant_terminal_config")
public class MerchantTerminalConfig {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id",unique = true, nullable = false)
private int id;
@Column(name="merchant_id")
private int merchantId;
@Column(name="terminal_code")
private String terminalId;
@Column(name="terminal_desc")
private String terminalDesc;
@Column(name="store_code")
private String storeId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "merchant_id", nullable = false,insertable=false,updatable=false)
private MerchantProfile merchantProfile;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_code", nullable = false,insertable=false,updatable=false)
private MerchantStoreConfig storeConfig;
public MerchantStoreConfig getStoreConfig() {
return storeConfig;
}
public void setStoreConfig(MerchantStoreConfig storeConfig) {
this.storeConfig = storeConfig;
}
public MerchantProfile getMerchantProfile() {
return merchantProfile;
}
public void setMerchantProfile(MerchantProfile merchantProfile) {
this.merchantProfile = merchantProfile;
}
public String getTerminalDesc() {
return terminalDesc;
}
public void setTerminalDesc(String terminalDesc) {
this.terminalDesc = terminalDesc;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public String getTerminalId() {
return terminalId;
}
public void setTerminalId(String terminalId) {
this.terminalId = terminalId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
}
package com.mtaka.finsol.model;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "merchant_store_config")
public class MerchantStoreConfig {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
private int id;
@Column(name = "merchant_id")
private int merchantId;
@Column(name = "store_name")
private String storeName;
@Column(name = "store_code")
private String storeCode;
@Column(name = "address1")
private String address1;
@Column(name = "address2")
private String address2;
@Column(name = "city")
private String city;
@Column(name = "state")
private String state;
@Column(name = "country")
private String country;
@Column(name = "postal_code")
private String postalCode;
@Column(name = "pos_Message")
private String posMessage;
@Column(name = "creation_date")
private String creationDate;
@Column(name = "address1_Lat")
private String address1Lat;
@Column(name = "address1_Long")
private String address1Long;
@Column(name = "address2_Lat")
private String address2Lat;
@Column(name = "address2_Long")
private String address2Long;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "storeConfig")
private Set<MerchantTerminalConfig> terminalConfig=new HashSet<MerchantTerminalConfig>(0);
public Set<MerchantTerminalConfig> getTerminalConfig() {
return terminalConfig;
}
public void setTerminalConfig(Set<MerchantTerminalConfig> terminalConfig) {
this.terminalConfig = terminalConfig;
}
public String getAddress1Lat() {
return address1Lat;
}
public void setAddress1Lat(String address1Lat) {
this.address1Lat = address1Lat;
}
public String getAddress1Long() {
return address1Long;
}
public void setAddress1Long(String address1Long) {
this.address1Long = address1Long;
}
public String getAddress2Lat() {
return address2Lat;
}
public void setAddress2Lat(String address2Lat) {
this.address2Lat = address2Lat;
}
public String getAddress2Long() {
return address2Long;
}
public void setAddress2Long(String address2Long) {
this.address2Long = address2Long;
}
public String getCreationDate() {
return creationDate;
}
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "merchant_id", nullable = false,insertable=false,updatable=false)
private MerchantProfile merchantProfile;
public MerchantProfile getMerchantProfile() {
return merchantProfile;
}
public void setMerchantProfile(MerchantProfile merchantProfile) {
this.merchantProfile = merchantProfile;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getPosMessage() {
return posMessage;
}
public void setPosMessage(String posMessage) {
this.posMessage = posMessage;
}
}
例外是:
Hibernate: select this_.id as id19_0_, this_.merchant_id as merchant2_19_0_, this_.store_code as store3_19_0_, this_.terminal_desc as terminal4_19_0_, this_.terminal_code as terminal5_19_0_ from merchant_terminal_config this_ where this_.merchant_id=? and this_.store_code=? and this_.merchant_id=? and this_.store_code=? and this_.merchant_id=? and this_.store_code=?
org.hibernate.exception.DataException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at com.mtaka.finsol.dao.UserDAO.getMerchatStoreTerminalList(UserDAO.java:167)
at com.mtaka.finsol.serviceImpl.UserDetailServiceImpl.getMerchatStoreTerminalList(UserDetailServiceImpl.java:160)
at com.mtaka.finsol.action.CreateStoreTerminalAction.validate(CreateStoreTerminalAction.java:50)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doBeforeInvocation(ValidationInterceptor.java:249)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:261)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
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:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
**Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '5.677755704167E12' in column '3' is outside valid range for the datatype INTEGER.**
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:999)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.throwRangeException(ResultSetImpl.java:7819)
at com.mysql.jdbc.ResultSetImpl.parseIntAsDouble(ResultSetImpl.java:7062)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2623)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2734)
at org.hibernate.type.IntegerType.get(IntegerType.java:51)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:173)
at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:126)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2114)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1404)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332)
at org.hibernate.loader.Loader.getRow(Loader.java:1230)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 66 more
Hibernate: select this_.id as id19_0_, this_.merchant_id as merchant2_19_0_, this_.store_code as store3_19_0_, this_.terminal_desc as terminal4_19_0_, this_.terminal_code as terminal5_19_0_ from merchant_terminal_config this_ where this_.merchant_id=? and this_.store_code=? and this_.merchant_id=? and this_.store_code=? and this_.merchant_id=? and this_.store_code=? and this_.merchant_id=? and this_.store_code=?