3 Replies Latest reply on Oct 17, 2006 10:31 AM by Newsgroup_User

    Type Coercion failed using Hibernate adapter

      Hi -

      I am using the HibernateAssembler that comes with FDS2. The objects that are sent to the server are stored correctly in the database, but the client receives the following exception:

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.data.messages::DataMessage@d05ab81 to mx.data.messages.SequencedMessage.
      at ConcreteDataService.as$38::CreateItemCommitResponder/ConcreteDataService.as$38:CreateItem CommitResponder::createResultEvent()[C:\dev\enterprise_gmc\frameworks\mx\data\ConcreteData Service.as:4565]
      at mx.data::CommitResponder/mx.data:CommitResponder::dispatchResultEvents()[C:\dev\enterpris e_gmc\frameworks\mx\data\CommitResponder.as:534]
      at mx.data::CommitResponder/result()[C:\dev\enterprise_gmc\frameworks\mx\data\CommitResponde r.as:378]
      at mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_gmc\frameworks\mx\rpc\AsyncRequest.a s:82]
      at NetConnectionChannel.as$37::NetConnectionMessageResponder/NetConnectionChannel.as$37:NetC onnectionMessageResponder::resultHandler()[C:\dev\enterprise_gmc\frameworks\mx\messaging\c hannels\NetConnectionChannel.as:407]
      at mx.messaging::MessageResponder/result()[C:\dev\enterprise_gmc\frameworks\mx\messaging\Mes sageResponder.as:202]

      I create a person object like the following:

      public class Person
      public function person():void {
      public var personId:Number;
      public var lastName:String;
      public var firstName:String;
      public var middleName:String;
      public var namePrefix:String;
      public var nameSuffix:String;
      public var addressSet:ArrayCollection = new ArrayCollection();

      I have an address object like the following:

      public class Address
      public function Address():void {
      public var addressId:Number;
      public var addressType:String;
      public var preferredAddress:Number;
      public var address1:String;
      public var address2:String;
      public var city:String;
      public var state:String;
      public var zipcode:String;
      public var country:String;
      public var county:String;
      public var version:Number;

      I create a person object and 2 address objects. I add the address objects to the arrayCollection of the person. Then I do the following:

      var personDS:DataService = new DataService("person");
      personDS.autoCommit = true;

      This creates both the person and address rows in the database correctly, but then throws the exception above. Not sure what the issue is. If I don't add the address objects to the collection, then it works fine and does not throw the exception. However, once I add 1 address object to the collection, it throws the exception.

      On the server side, the collection is mapped to a java.util.Set using a HashSet. Again, it persists okay, but throws the client exception.

      Any thoughts would be helpful.