errore: java.lang.String non può essere gettato a coldfusion.cfc.CFCBeanProxy Qualcuno sa su questo?

StackOverflow https://stackoverflow.com/questions/2746583

Domanda

Qualcuno sa su questo errore ottengo quando provo ad inserire un valore chiave esterna nella mia entità entry con l'integrazione di ColdFusion 9 Hibernate?

  

java.lang.ClassCastException: java.lang.String non può essere lanciato a coldfusion.cfc.CFCBeanProxy

     

La causa all'origine: org.hibernate.HibernateException: java.lang.ClassCastException: java.lang.String non può essere lanciato a coldfusion.cfc.CFCBeanProxy

Di seguito è riportato il codice per il mio oggetto entità e poi per il mio oggetto utente ..

C'è sbagliato qualcosa con questo?

entry.cfc

/**
* Entries Object
*/
component output="false" persistent="true"{
    property name="entry_id" fieldType="id" generator="uuid";
    property name="entryBody" ormType="text";
    property name="title" notnull="true" type="string";
    property name="time" fieldtype="timestamp";
    property name="isCompleted" ormType="boolean" dbdefault="0" default="false";
    property name="userID" fieldtype="many-to-one" fkcolumn="userID" cfc="user";

    Entry function init() output=false{
        return this;
    }
}

user.cfc

/**
* Users Object
*/
component output="false" persistent="true"{
    property name="userID" fieldType="id" generator="uuid";
    property name="firstName" notnull="true" type="string";
    property name="lastName" notnull="true" type="string";
    property name="password" notnull="true" type="string";
    property name="userType" notnull="true" type="string";
    //property name="entry" fieldtype="one-to-many" type="array" fkcolumn="userID" cfc="entry";

    User function init() output=false{
        return this;
    }
}
È stato utile?

Soluzione

property name="user" type="User" fieldtype="many-to-one" fkcolumn="userID" cfc="User";

Poiché la proprietà dovrebbe essere di tipo utente, non l'ID? In CF-ORM / Hibernate, non c'è modo per appena impostato FK. È necessario ...

entry = EntityNew("Entry");
user = EntityLoadByPK("user",1);
entry.setUser(user);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top