[英]Hibernate Exception : java.sql.SQLException: Invalid value for getInt() - 'T2'
[英]java.sql.SQLException: Invalid value for getInt() - 'foo'
我有這個錯誤“getInt()的無效值 - 'sirocodir'”,我在很多論壇搜索但我的情況沒有回復。
在我的數據庫中,“Auteur_Id”類型是varchar(20)。
我的制作實體:
@Entity
@Table(name = "Factures")
public class Factures implements java.io.Serializable {
private Collaborateurs collaborateurs;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Auteur_Id", nullable = false)
public Collaborateurs getCollaborateurs() {
return this.collaborateurs;
}
public void setCollaborateurs(Collaborateurs collaborateurs) {
this.collaborateurs = collaborateurs;
}
我的Collaborateurs實體:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "collaborateurs")
public Set<Factures> getfactures() {
return this.factures;
}
public void setfactures(Set<Factures> factures) {
this.factures = factures;
}
我的服務:
@Transactional(readOnly=true)
public List<Factures> AllFacturesContratsClient() {
return sessionFactory.getCurrentSession()
.createQuery("from Factures").list();
}
記錄tomcat:
Caused by: java.sql.SQLException: Invalid value for getInt() - 'sirocodir'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2725)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2813)
at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:237)
at org.hibernate.type.IntegerType.get(IntegerType.java:51)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:186)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:175)
at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:158)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2267)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1443)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1371)
at org.hibernate.loader.Loader.getRow(Loader.java:1271)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:619)
at org.hibernate.loader.Loader.doQuery(Loader.java:745)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.doList(Loader.java:2449)
... 126 more
在Collaborateurs
課程中你有任何枚舉類型嗎? 如果有,請確保使用@Enumerated(EnumType.STRING)
在進行架構更改后我得到了這個。 可能遷移工作不正常。 丟棄表並重新生成后,錯誤就消失了。
由於實體之間的映射不正確,也會發生此異常。 在我們的例子中,我們在兩個實體之間的關系映射錯誤 我們通過糾正實體之間的關系解決了這個
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.