I am having a similar problem. I have DB rows that contain (null) in an Oracle Database. I am using java.lang.Float in my mapping file and in my java class. Still when I query the DB I get a PropertyAccessException error.
Here is my mapping file:
Code:
<hibernate-mapping>
<class name="abhto.abhc.core.ResultsNeuroReyOsterreithComplexFigure" table="RESULTS_NEURO_ROCOMPLEXFIGURE">
<!--cache usage="nonstrict-read-write"/-->
<id name="id" type="java.lang.Long">
<generator class="seqhilo">
<param name="sequence">abhc_data.ID_HI_SEQUENCE</param>
<param name="max_lo">100</param>
</generator>
</id>
<property name="surveyDate" type="java.util.Date" />
<property name="testDate" type="java.util.Date" />
<property name="CRS" type="java.lang.Float" />
<property name="CP" type="java.lang.String" />
<property name="threeMDRS" type="java.lang.Float" />
<property name="threeMDTS" type="java.lang.String" />
<property name="thirtyMDRS" type="java.lang.Float" />
<property name="thirtyMDTS" type="java.lang.String" />
<!-- Associations -->
<!-- uni-directional many-to-one association to Patient -->
<many-to-one
name="patient"
class="abhto.abhc.core.Patient"
column="patient"
index="resmonthrisk_patient_index" />
<!-- uni-directional many-to-one association to Site -->
<many-to-one name="site" class="abhto.abhc.core.Site">
<column name="site" />
</many-to-one>
</class>
<database-object>
<create>GRANT SELECT, INSERT, UPDATE ON ABHC_DATA.RESULTS_NEURO_ROCOMPLEXFIGURE TO ABHC_APP, ABHC_WEBSERVICE, ABHC_RECOVERER</create>
<drop></drop>
</database-object>
</hibernate-mapping>
My Java Class is simply this:
Code:
package abhto.abhc.core;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.Session;
import abhto.abhc.action.secure.GetScoresFromLookup;
import abhto.abhc.scoring.n2k.RCFTRaw18Lookup;
import abhto.util.hibernate.HibernateUtil;
public class ResultsNeuroReyOsterreithComplexFigure implements abhto.abhc.ModuleResults, java.io.Serializable{
private static final long serialVersionUID = 1L;
private Long id;
private Date surveyDate;
private Date testDate;
private Float CRS;
private String CP;
private Float threeMDRS;
private String threeMDTS;
private Float thirtyMDRS;
private String thirtyMDTS;
private Patient patient;
private Site site;
public ResultsNeuroReyOsterreithComplexFigure(){}
public ResultsNeuroReyOsterreithComplexFigure(Date surveyDate, Date testDate, Float CRS, String CP,
Float threeMDRS, String threeMDTS, Float thirtyMDRS, String thirtyMDTS,
Patient patient, Site site){
this.surveyDate = surveyDate;
this.testDate = testDate;
this.CRS = CRS;
this.CP = CP;
this.threeMDRS = threeMDRS;
this.threeMDTS = threeMDTS;
this.thirtyMDRS = thirtyMDRS;
this.thirtyMDTS = thirtyMDTS;
this.patient = patient;
this.site = site;
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Date getSurveyDate() {
return this.surveyDate;
}
public void setSurveyDate(Date surveyDate) {
this.surveyDate = surveyDate;
}
public Date getTestDate(){
return this.testDate;
}
public void setTestDate(Date testDate){
this.testDate = testDate;
}
public Float getCRS() {
return this.CRS;
}
public void setCRS(Float CRS) {
this.CRS = CRS;
setCP(null);
}
public String getCP() {
if(CP == null){
getPercentileForROCFCopyScore();
}
return this.CP;
}
public void setCP(String CP) {
this.CP = CP;
}
public Float getThreeMDRS() {
return this.threeMDRS;
}
public void setThreeMDRS(Float threeMDRS) {
this.threeMDRS = threeMDRS;
setThreeMDTS(null);
}
public String getThreeMDTS() {
if(threeMDTS == null){
getTScoresForROCF3Min();
}
return this.threeMDTS;
}
public void setThreeMDTS(String threeMDTS) {
this.threeMDTS = threeMDTS;
}
public Float getThirtyMDRS() {
return this.thirtyMDRS;
}
public void setThirtyMDRS(Float thirtyMDRS) {
this.thirtyMDRS = thirtyMDRS;
setThirtyMDTS(null);
}
public String getThirtyMDTS(){
if(thirtyMDTS == null){
getTScoresForROCF30Min();
}
return this.thirtyMDTS;
}
public void setThirtyMDTS(String thirtyMDTS){
this.thirtyMDTS = thirtyMDTS;
}
public Patient getPatient() {
return this.patient;
}
public void setPatient(Patient patient) {
this.patient = patient;
}
public Site getSite() {
return this.site;
}
public void setSite(Site site) {
this.site = site;
}
/**
* toString
* @return String
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(getClass().getName()).append("@").append(Integer.toHexString(hashCode())).append(" [");
buffer.append("id").append("='").append(getId()).append("' ");
buffer.append("]");
return buffer.toString();
}
public void getPercentileForROCFCopyScore(){
Float rawScore = this.getCRS();
if(rawScore == null || patient == null){
return;
}
String results = "";
GetScoresFromLookup getScoresFromLookup = new GetScoresFromLookup();
ResultsNeuroPatientDemog res = (ResultsNeuroPatientDemog)patient.getLatestResults("PatientDemog");
Integer patAge = res.getAge();
results = getScoresFromLookup.getPercentileFromROCFLookupByCopyRawScore(patAge, rawScore);
setCP(results);
}
public void getTScoresForROCF3Min(){
Float threeMinRaw = this.getThreeMDRS();
if(threeMinRaw == null || patient == null){
return;
}
String results = "";
String type = "threeMin";
GetScoresFromLookup getScoresFromLookup = new GetScoresFromLookup();
ResultsNeuroPatientDemog res = (ResultsNeuroPatientDemog)patient.getLatestResults("PatientDemog");
Integer patAge = res.getAge();
results = getScoresFromLookup.getTScoreFromROCFLookupByAge(patAge, threeMinRaw, type);
this.setThreeMDTS(results);
}
public void getTScoresForROCF30Min(){
Float thirtyMinRaw = this.getThirtyMDRS();
if(thirtyMinRaw == null || patient == null){
return;
}
String results = "";
String type = "thirtyMin";
GetScoresFromLookup getScoresFromLookup = new GetScoresFromLookup();
ResultsNeuroPatientDemog res = (ResultsNeuroPatientDemog)patient.getLatestResults("PatientDemog");
Integer patAge = res.getAge();
results = getScoresFromLookup.getTScoreFromROCFLookupByAge(patAge, thirtyMinRaw, type);
setThirtyMDTS(results);
}
}
The fields in question in the DB are set up as number(10,1). So according to the FAQ and all the other posts I have read online, you can't use float, double or int, instead you must use Float, Double, or Integer. I am using the latter and still getting this exception error.
Does anyone know why or if there is a work around other than changing (null) values to 0 or other?
Thanks, John