Reputation: 531
My java application is using hibernate with Oracle 10g as the database. I have landed into an issue and not able to proceed and i need your help here. Below is the issue that i am facing.
I have a Column in one of my Oracle table which has a datatype of Varchar2(1 byte)
.
I want to know the proper dataype that i need to use in my pojo class.
Also in the hibernate mapping file what should be the datatype for the same property.
when i am running the file hibernate keeps on giving error like cannot do a conversion.
below are my pojo and .hbm
file
public class destination implements Serializable{
private String configId;
private String isCurrent;
//other properties and getter, setters
}
destination.hbm.xml
<class name="com.testing" table="configuration">
<id name="configID" type="java.lang.Integer">
<column name="configuration_id" />
<generator class="identity" />
</id>
<property name="isCurrent" type="Not-SURE">
<column name="is_current" not-null="true" />
</property>
The column i am talking about is the isCurrent
property in the pojo and .hbm.xml
file.
Its defined as Varchar2(1 byte)
in the db. I ma not sure about the datatype and marked it a String
but the issue still persists.
I have searched the net but have not got any proper solution for this issue.
Can you please help me here as its really eating my head a lot.
Upvotes: 0
Views: 1735
Reputation: 51
Im guessing you want to store current flag on the record. In that case you can do
public class destination implements Serializable{
private String configId;
private boolean current;
public boolean isCurrent() {
return current;
}
}
and hbm mapping like
<property name="current" type="yes_no">
<column name="is_current" not-null="true" />
</property>
Upvotes: 0
Reputation: 3485
I would focus on the configId you declared it as String in the class but as Integer in the xml.
<id name="configID" type="java.lang.Integer">
Upvotes: 1