In our Oracle database there exists a lot of tables having CHAR columns. Unfortunately we cannot switch to VARCHAR2 data types.
Example:
CREATE TABLE DUMMY_TAB
( LINE_NO NUMBER(5),
LINE_DATA CHAR(10 byte),
CONSTRAINT "PK_DUMMY" PRIMARY KEY("LINE_NO")
);Using seam generate-model
an entity bean is created:
@Entity
@Table(name = "DUMMY_TAB")
public class DummyTab implements java.io.Serializable
{
:
:
@Column(name = "LINE_DATA", length = 10)
@Length(max = 10)
public String getLineData()
{
return this.lineData;
}
public void setLineData(String lineData) {
this.lineData = lineData;
}
}
While deploying using seam restart
following HibernateException is displayed:
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: persistence.units:ear=DspProofOfConcept.ear, jar=DspProofOfConcept.jar,unitName=DspProofOfConcept State: FAILED Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: LINE_DATA, expected: varchar2(10)
I unsuccessfully tried to use columnDefinition
in order to tell hibernate to use CHAR datatype
@Column(name="LINE_DATA", length=10, columnDefinition="CHAR")
@Length(max = 10)
public String getLineData()
{
return this.lineData;
}The same exception is thrown while deploying the app.
Any ideas?
Solution:
The value defined with columnDefinition is case sensitiv.
So please use
columnDefinition="char"
instead of
columnDefinition="CHAR"