Hi,
I have done some tests with nested embedded objects using native queries. I wanted to identify all node properties of the above WithEmbedded persistence object.
WithEmbedded with = new WithEmbedded( 1L, "name-1", new AnEmbeddable( "string-1", new AnotherEmbeddable( "string-2", 2 ) ) ); with.setYetAnotherEmbeddable( new AnEmbeddable( "string-3", null ) );
WithEmbedded with2 = new WithEmbedded( 2L, "name-2", new AnEmbeddable( "string-10", new AnotherEmbeddable( "string-20", 20 ) ) ); with2.setYetAnotherEmbeddable( new AnEmbeddable( "string-30", null ) );
Native Query: session.createNativeQuery("MATCH (e:WithEmbedded) WITH {withEmbedded: str(e)}
as withEmbeddeds RETURN {withEmbeddeds: collect(withEmbeddeds)}
").list();
Result: [{withEmbeddeds=[{withEmbedded=Node[6]{id:1,name:"name-1"}}, {withEmbedded=Node[10]{id:2,name:"name-2"}}]}]
It seems somehow cypher is not capable to identify nested properties, only the name property which is part of WithEmbedded is identified.
Success: session.createNativeQuery("MATCH (e:WithEmbedded) WHERE e.name = 'name-1' return e").addEntity(WithEmbedded.class).list(); --> returns a single object
Failure: session.createQuery( "from WithEmbedded e where e.anEmbeddable.embeddedString = 'string-1'" ).list(); --> returns two objects instead of one
The consequence is that all nested unit tests will fail because cypher can not identify the properties the filter should get applied on to.
Did I miss something?
|