I have this error "Invalid value for getInt() - 'sirocodir'" , i have search in many forum but no response for my case.
In my database the "Auteur_Id" type is a varchar(20).
My Facture Entity:
@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;
}
My Collaborateurs entity:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "collaborateurs")
public Set<Factures> getfactures() {
return this.factures;
}
public void setfactures(Set<Factures> factures) {
this.factures = factures;
}
My service:
@Transactional(readOnly=true)
public List<Factures> AllFacturesContratsClient() {
return sessionFactory.getCurrentSession()
.createQuery("from Factures").list();
}
Log 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
Do you have any enum type in the class Collaborateurs
?
If it has, make sure use @Enumerated(EnumType.STRING)