(i have Hibernate 3.2.3)
Hi, i was tring to make an Entity class that match a table that I have in my Sybase DB. that table's structure can't be modified because belongs to another legacy system.
My problem was that some columns data types was 'real', and it seems to be that SybaseDialect (or Sybase11Dialect) does not have the 'real' type (java.sql.Types = 7) registered, so i couldn't make a match defining the attribute in my class as float nor double.
So... what i did is to create a subclass or SybaseDialect like this:
Code:
import java.sql.Types;
public class SybaseDialect extends org.hibernate.dialect.SybaseDialect {
public SybaseDialect() {
super();
registerColumnType(Types.REAL, "real");
}
}
next, I had to create a data type in this way:
Code:
import java.sql.Types;
import org.hibernate.type.FloatType;
public class RealType extends FloatType {
public int sqlType() {
return Types.REAL;
}
public String getName() {
return "real";
}
}
later, Hibernate stopped complaining about expected data types complainings.
I don't know (i couldn't found nothing) if there's a better way, or if the problem is already solved, but if it's solved, please someone tell me :D (i don't like making custom dialects and datatypes for such a common thing)
Now i would like to declare my new type using @TypeDef annotation but Hibernate keep complaining like if i never write the Typedef.
this is my definition... (i putted it at class level)
Code:
@TypeDef(name = "real", typeClass = RealType.class, parameters = {})
or
Code:
@TypeDef(name = "real", typeClass = RealType.class)
and in my class i use it like this:
Code:
@Type(type = "real")
@Column(name = "heatingValue", nullable = false)
private float heatingValue;
This is the Exception:
Code:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: real, for columns: [org.hibernate.mapping.Column(heatingValue)]
I will appreciate some light here... thanks!