Hi, Im having trouble with char mapping to String.
I have a table called "mrconso" in my MySQL database and the following entity:
@Entity
@Table(name = "MRCONSO")
@NamedQuery(name = "mrconsoStr", query = "select i from Mrconso i where str like :terms")
public class Mrconso implements Serializable {
private Blob str;
private String cui;
@Id
@GeneratedValue
public Blob getStr() {
return str;
}
public void setStr(Blob str) {
this.str = str;
}
public String getCui() {
return cui;
}
public void setCui(String cui) {
this.cui = cui;
}
}
there is a problem with the "cui" field; in the database it is a char(8) but I want it as a String when I recover it from the entity. If the entity is defined as I wrote before, I get the following error:
HibernateException: Wrong column type: cui, expected: varchar(255)
I think the problem comes because it is a char(8) and not varchar(8) because I have other fields that are varchar and I dont get problems with that.
What should I do?
thanks in advance
Hibernate version:
3.1.3
Full stack trace of any exception that occurs:
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: persistence.units:ear=WP7.ear,jar=WP7.jar,unitName=WP7
State: FAILED
Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: cui, expected: varchar(255)
I Depend On:
jboss.jca:service=DataSourceBinding,name=WP7Datasource
Depends On Me:
jboss.j2ee:ear=WP7.ear,jar=WP7.jar,name=SearchBean,service=EJB3
Name and version of the database you are using:
Mysql 5.0.37
|