Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

DataServices/Hibernate Issue when Deleting

Avatar

Level 2
I am having strange issues with a managed item that has a
collection of child items. So, here is the scenario:



Organization bean has many different properties and an
ArrayCollection of Locations.



In the database, the Locations are mapped as a one-to-many
association with a foreign key reference back to the organization
table. So, I have an Organization bean with an ArrayCollection of
Location beans.



I get the organization from the server which comes back with
its ArrayCollection of Location objects.

I remove one of the Location objects from the
ArrayCollection.

I then commit the change.



On the server in the HibernateAssember, I first get an
updateItem method call. THE PROBLEM is that the set of Locations is
now empty. It doesn't appear as though the entire bean graph is
being sent down to the Hibernate Assembler. I check the client
before the commit and the array collection looks correct, but the
set is empty once it gets to the Hibernate Assembler. I would think
that the bean graph would be intact. So the upshot is that the
Hibernate Assembler things that the set of Locations has been
deleted and creates an Update set organizationId = null;



This seems wrong. Any thoughts?



Thanks,

Tom
4 Replies

Avatar

Level 2
Yeah, the updateItem call should have the proper value of the
"locations" property. The first thing I'd check is that you have
set up the "identity" property for the location destination
correctly. If it has the wrong property name, it won't be able to
map ids to items correctly and so would get the empty value.



If that isn't the problem, could you enable debug logging on
the server and include the debug logs? You'd go to
WEB-INF/flex/services-config.xml, search for "level=", change that
to Debug and be sure that your patterns has both Message.* and
Endpoint.*. It should contain enough info so we can see what is
going wrong.

Avatar

Level 2
Thanks for your reply. Here is the debug message on the
server:



[Flex][INFO] Channel endpoint my-secure-http received
request.

[Flex][DEBUG] Deserializing AMFX/HTTP request

Version: 3

(Message #0 targetURI=null, responseURI=null)

(Typed Object #0 'flex.messaging.messages.RemotingMessage')

body = (Array #1)

(Typed Object #2 'com.presidio.organization.Organization')

active = 1

billingVendorMasterId = 21

bpmWorkflowName = "aaaaWorkflow.par"

codingVendorMasterId = 102

createWho = "AAAAA3"

lastWho = null

locationSet = (Typed Object #3
'flex.messaging.io.ArrayCollection')

(Byte Array #3, Length 788)

name = "Name is not shown"

organizationCode = "AAAA"

organizationId = 10

uid = "10"

clientId = null

destination = "userMasterService"

(Object #4)

DSEndpoint = "my-secure-http"

headers = messageId = "6593CEAC-E963-C47D-D710-396990BB6404"

operation = "checkOrganization"

source = null

timestamp = 0

timeToLive = 0



As you can see, this shows the locationSet has 3 entries. But
on the server, when the object arrives, the locationSet is empty.
Help, Please!!!

Avatar

Level 2
I am actually a little confused. This is a RemotingMessage
which means it is sent from the client to the server when you
"send" a RemoteObject request. In this case, it is to the
destination "userMasterService" to the "checkOrganization" method.
Probably this is just a debug call you added and so not related to
the original problem? I'm looking to see the messages of type
DataMessage... in particular there would be a "batched" message
which would contain one or more "update", "create" etc
messages.

Avatar

Level 2
Hi jvroom -



Thanks for your response. I've been trying everything from
sending message back through to the HibernateAssembler and also
just trying it through an RPC call. The same behavior is present. I
have, however, found a work around for it.....



The Organization java object had the locationSet as a
Set/HashSet declared for the set. I did this in order to use the
HIbernate set notation, instead of having to use an indexed List.
However, when I changed the Java object to a List, then it worked.
It appears as though, for some reason, serialization does not work
when declaring a Set. Not sure why since the Flex documentation
explicitly allows a Set/HashSet on the java side.



Any thoughts about that? Anyway, that was the solution that I
found. Hibernate does act a little strangely though given the way
the Hibernate Assembler compares the changes. For example, even
though I get the entire graph on the client, if I delete one of the
locations in the list, the server will only NULL out the foreign
key, instead of deleting the row. In my unit test on the server
going straight to Hibernate, it deletes the row. So, what I need to
do on the client is get the organizations and get the locations
seperately. When I delete from the location list, and then commit,
it works fine.



I'll do some more playing around with it, but I would assume
that if I delete a bean in a set that it would reflect the same
change through hibernate.



Thanks,

Tom