2
votes

I am receiving the following error when attempting to load an object using ORM:

[Macromedia][SQLServer JDBC Driver]Unsupported data conversion.

Code:

<cfscript>
    order = entityLoadByPK('orders',session.orderid);
</cfscript>

The value of session.orderid = 1001 I tried trimming it just in case there were some extra spaces on it. No dice.

Here is my table:

enter image description here

Here is my CFC:

component  output="false" persistent="true" table="orders" accessors="true"
{ 
    property name="o_id"        column="o_id"       getter="true"   setter="false"  fieldtype="id"  generator="identity"; 
    property name="o_cust_id"       column="o_cust_id"      getter="true"   setter="true" type="numeric"    sqltype="cf_sql_integer"; 
    property name="o_cart_id"       column="o_cart_id"      getter="true"   setter="true" type="numeric"    sqltype="cf_sql_integer"; 
    property name="o_item_count"        column="o_item_count"       getter="true"   setter="true" type="numeric"    sqltype="cf_sql_integer"; 
    property name="o_timestamp"     column="o_timestamp"        getter="true"   setter="true" ORMtype="date"    sqltype="cf_sql_timestamp"; 
    property name="o_subtotal"      column="o_subtotal"     getter="true"   setter="true" ORMtype="date"    sqltype=""; 
    property name="o_status"        column="o_status"       getter="true"   setter="true" type="string" sqltype="cf_sql_varchar"; 
    property name="o_tax_rate"      column="o_tax_rate"     getter="true"   setter="true" type="string" sqltype=""; 
    property name="o_tax_cost"      column="o_tax_cost"     getter="true"   setter="true" type="string" sqltype=""; 
    property name="o_promo_code"        column="o_promo_code"       getter="true"   setter="true" type="string" sqltype="cf_sql_varchar"; 
    property name="o_promo_value"       column="o_promo_value"      getter="true"   setter="true" type="string" sqltype=""; 
    property name="o_total"     column="o_total"        getter="true"   setter="true" type="string" sqltype=""; 
    property name="o_completed"     column="o_completed"        getter="true"   setter="true" type="char"   sqltype="cf_sql_bit"; 
    property name="o_completed_date"        column="o_completed_date"       getter="true"   setter="true" type="char"   sqltype="";

    public function init(){
        return this;
    }
}

This one has me baffled.

1
I have modified the entry to include the cfc and my session value. Thanks for your help. - Sollinger04
Sorry. I couldn't get the code to display correctly, but I figured it out. - Sollinger04
For the sake of experiment, hard-code 1001 in there. If that works, do this: gist.github.com/daccfml/8474140 - Adam Cameron
I just tried that. Same error. I even tried dropping and recreating the table. - Sollinger04

1 Answers

1
votes

I figured this out. Apparently there is a bug in the SQL Server JDBC driver (Microsoft HotFix). When a null value is in a datetime field an error occurs when attempting to retrieve the data.

I thought the problem field was my id field, but it was really the datetime field. Since I am only using this field as a timestamp, I just changed the data type to a varchar field and the error goes away.