Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Type Coercion failed using Hibernate adapter

Avatar

Level 2
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:CreateItemCommitResponder::createResultEvent()[C:\dev\enterprise_gmc\frameworks\mx\data\ConcreteDataService.as:4565]

at
mx.data::CommitResponder/mx.data:CommitResponder::dispatchResultEvents()[C:\dev\enterprise_gmc\frameworks\mx\data\CommitResponder.as:534]

at
mx.data::CommitResponder/result()[C:\dev\enterprise_gmc\frameworks\mx\data\CommitResponder.as:378]

at
mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_gmc\frameworks\mx\rpc\AsyncRequest.as:82]

at
NetConnectionChannel.as$37::NetConnectionMessageResponder/NetConnectionChannel.as$37:NetConnectionMessageResponder::resultHandler()[C:\dev\enterprise_gmc\frameworks\mx\messaging\channels\NetConnectionChannel.as:407]

at
mx.messaging::MessageResponder/result()[C:\dev\enterprise_gmc\frameworks\mx\messaging\MessageResponder.as:202]



I create a person object like the following:



[Managed]

[RemoteClass(alias="com.cmcc.person.Person")]

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:



[Managed]

[RemoteClass(alias="com.cmcc.address.Address")]

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;

personDS.createItem(person);



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.



Thanks,

Tom



3 Replies

Avatar

Level 3
Hi,



Unforturnately, I think it is a bug. I got the same error
when I createItem to an empty collection in nested destination. If
the destination already have data, it has no problem. Have to
seperate the process by adding the parent before its children. I am
going to log this bug!



William Chan

Avatar

Level 2
Hi All -



I got this working by changing the autoCommit = false and
manually commiting after the createItem call. Not sure why, but it
seemed to work. An explanation as to why autoCommit would cause
this problem would be helpful when you know.



Thanks for your help.

Tom

Avatar

Former Community Member
Hi All -



I got this working by changing the autoCommit = false and
manually commiting

after the createItem call. Not sure why, but it seemed to
work. An

explanation as to why autoCommit would cause this problem
would be helpful when

you know.



Thanks for your help.

Tom