You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Todd Nine <to...@spidertracks.com> on 2011/04/08 00:53:59 UTC

Help with Embedded objects and statemanager detachment

Hi all,
  I'm having a very difficult time working with embedded entities in
Cassandra.  Specifically, this is the case where I'm getting very
strange behavior.    Em = Entity Manager.

em created
em begin transaction
em  load User entity , the embedded Address object is correct.
em  complete transaction

User entity is now detached.

Address is updated

em  begin transaction
User is attached, and address is as well

em.save(User) is invoked
em  flush

em commit transaction


The Address now has a null entity manager, and all fields are null,
however it is correct when the entity was passed to the flush operation
before using StateManager.get(fieldId) to retrieve the embedded object. 

For the Cassandra plugin in it's first implementation, we're requiring
all @Embeddable entities to also implement Serializable.  The embedded
entity value is simply serialized to a column    

Here is the embedded column implementation I have created for @Embedded


https://github.com/riptano/hector-jpa/blob/master/src/main/java/com/datastax/hectorjpa/meta/embed/EmbeddedColumnField.java

Here is the implementation for @ElementCollection where the elements in
the collection are @Embeddable

https://github.com/riptano/hector-jpa/blob/master/src/main/java/com/datastax/hectorjpa/meta/embed/EmbeddedableCollectionColumnField.java

Any guidance would be greatly appreciated.  I know I'm not wiring the
entity manager correctly during load, I'm just unsure what else I need
to do.  I've looked at both ElementEmbedValueHandler and
EmbedFieldStrategy, however I'm not getting anywhere.  Any help would be
greatly appreciated.

Thanks in advance!

Todd