Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Parent Child Hierarchy with FDS and Hibernate

Avatar

Level 1
I know my chances of getting heard here are slim, but I am at
a dead end, so here goes.



I have a four level hierarchy of objects

PlanPoint

....UserScenario

........Scenario

............Competitor

which have bi-directional one-to-many relationships between
them.



I have made sure that my hibernate mappings and FDS
destination are matched and I definitely need to have managed
associations as the graph of objects will grow large in my
application (and besides, it is good development practice). So I
have a fully formed project (or at least I think I do) and I get a
duplicate object error.



Right at the bottom I have an alternative that I have tried
which gives a different error.



Here is a snippet from my log... it picks up just after the
message arrives



2007-02-05 21:21:10,281 INFO [STDOUT] Hibernate: insert into
COMPETITOR (COMPETITOR_ID, SCENARIO_ID, NAME, X, Y, RADIUS, ACTUAL,
PROPOSITIONS, ORDER_SIZE, CONVERSION_RATE) values (null, ?, ?, ?,
?, ?, ?, ?, ?, ?)

2007-02-05 21:21:10,281 INFO [STDOUT] Hibernate: call
identity()

2007-02-05 21:21:10,312 INFO [STDOUT] Hibernate: insert into
SCENARIO (SCENARIO_ID, TITLE, SEQUENCE, POTENTIAL,
USER_SCENARIO_ID) values (null, ?, ?, ?, ?)

2007-02-05 21:21:10,312 INFO [STDOUT] Hibernate: call
identity()

2007-02-05 21:21:10,359 INFO [STDOUT] Hibernate: insert into
USER_SCENARIO (USER_SCENARIO_ID, TITLE, PLANPOINT_ID, AUTHOR)
values (null, ?, ?, ?)

2007-02-05 21:21:10,359 INFO [STDOUT] Hibernate: call
identity()

2007-02-05 21:21:10,406 INFO [STDOUT] [Flex] Serializing
AMF/RTMP response

Version: 3

(Command method=_error (0) trxId=8)

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

rootCause = (Typed Object #1
'org.hibernate.NonUniqueObjectException')

throwables = (Array #2)

[0] = (Ref #1)

localizedMessage = "a different object with the same
identifier value was already associated with the session:
[pmco.pojos.Competitor#0]"

message = "a different object with the same identifier value
was already associated with the session: [pmco.pojos.Competitor#0]"

identifier = 0

cause = null

throwableCount = 1

entityName = "pmco.pojos.Competitor"

messages = (Array #3)

[0] = "a different object with the same identifier value was
already associated with the session"

destination = "competitor.hibernate"

headers = (Object #4)

correlationId = "BFAF11E0-6121-54BB-A836-93C81DAE7772"

faultString = "Could not invoke sync method on data adapter
for destination 'userscenario.hibernate' due to the following
error: class org.hibernate.NonUniqueObjectException:a different
object with the same identifier value was already associated with
the session: [pmco.pojos.Competitor#0]."

messageId = "78CB9396-9618-519F-8DB0-70D4E53357FE"

faultCode = "Server.Processing"

timeToLive = 0.0

extendedData = null

faultDetail = null

clientId = null

timestamp = 1.17071047039E12

body = null



Anyone got any ideas?



I would provide my mappings and destinations but I can't fit
them in a message
2 Replies

Avatar

Former Community Member
I have been working with very hierarchical data with FDS and
EJB3.0 (hibernate on jboss4.0.5). I've avoided the direct mapping
between flex and Hibernate because of scenarios like this. I don't
like linking my persistence version/methodlogy directly to the
front end. Instead I've used the JavaAssembler strategy that works
directly with session EJBs. This has proven to work very well. Also
you may be getting this error because your mappings are not
correct. make sure your cascading properly. you will get this error
because you're trying to insert an object that Hibernate has
already inserted. hope this helps.

-JB

Avatar

Level 1
Hi,



thanks for the reply it was very helpful. I came to pretty
much the same conclusion and started on the path of a re-write of
the hibernate assembler myself. As far as I can tell the Hibernate
Assembler is a Java Assembler, so there didn't seem much difference
to me between fixing that one and writing another one. Adobe ship
the code.



Bit of a cheeky request, but I don't suppose you would be
willing to share your assembler layer so I have a template against
which to work? Biggest problem with this sort of activity is a lack
of examples which makes it very slow going and largely trial and
error.



If you would like to know more about our application I will
provide contact details so we can discuss.



Simon



PS Jeff Vroom posted a reply saying that the Adobe Hibernate
Assembler didn't work properly with hierarchical data (which I
imagine is every real application in the world), personally I think
Adobe should fix it or pull it.




http://tech.groups.yahoo.com/group/flexcoders/message/63961