Jan 12
This is one exception that can occur one day when you are using Hibernate and PostgreSQL. Basically it occur when you have an entity that has one float mapped property and you create one HQL query using the HQL built-in-functions, such as: SUM, AVG, COUNT, with left outer joins or simple queries.
org.hibernate.MappingException: No Dialect mapping for JDBC type: 7
There are two ways to solve the problem: the first is to change property type to Double and the second is to create a customized dialect:
public class PostgreSQLDialect extends org.hibernate.dialect.PostgreSQLDialect {
public PostgreSQLDialect() {
super();
registerColumnType(Types.REAL, ânumber($p,$s)â );
registerHibernateType(Types.REAL, âfloatâ);
}
}
SQL type 7 corresponds to JDBC float type, then we need to register column data type and register hibernate data type too.
Portuguese version
Oct 30
Esta Ă© uma exception que pode ocorrer algum dia com vocĂȘ quando estiver usando Hibernate e PostgreSQL. Basicamente ela ocorre quando vocĂȘ tem um a entidade que tem uma propriedade mapeada do tipo float, e vocĂȘ tenta criar uma consulta HQL usando as built-in-functions (sum, avg, count, etc), fazendo left outer joins, ou atĂ© mesmo com consultas simples.
org.hibernate.MappingException: No Dialect mapping for JDBC type: 7
HĂĄ duas maneiras de resolver o problema: a primeira Ă© alterando o tipo de dados de FLOAT para DOUBLE ou criando um dialeto personalizado:
public class PostgreSQLDialect extends org.hibernate.dialect.PostgreSQLDialect {
public PostgreSQLDialect() {
super();
registerColumnType(Types.REAL, “number($p,$s)” );
registerHibernateType(Types.REAL, “float”);
}
}
O SQL type 7, corresponde a dados do Tipo real, entĂŁo precisamos registrar o tipo de dados da coluna e relacionar este tipo de dados a um tipo de dados do hibernate.
VersĂŁo em InglĂȘs
Comentarios recentes