Great question.
You're not expected to override exists.
It should actually just work. I would appreciate a JIRA issue with the content
of this email. Not sure I understand it all, so a test-project with a failing
unit-test would be awesome.
Thanks a lot
Michael
I think most sense would make (this doesn't work yet I think), to coerce the
numeric result to a boolean
> @Override
> @Query(value = "match (n:Community) where id(n)={id} return count(n)")
> public boolean exists(@Param("id") Long id);
Am 05.03.2014 um 17:58 schrieb Grégoire Colbert <[email protected]>:
> Hi,
>
> I'm trying to override the "boolean exists(Long)" function in my
> CrudRepositories interfaces, and I think I have found an inconsistency in
> Cypher about the "return" clause.
>
> The method I want to add to "CommunityRepository" is :
>
> @Override
> @Query(value = "match (n:Community) where id(n)={id} return count(n) > 0")
> public boolean exists(@Param("id") Long id);
>
> What happens is this :
> - if the node whose "id" is given carries the label ":Community", then this
> request will return a boolean "true", which is the expected behaviour.
> - if the node doesn't carry the ":Community" label (for example it carries
> ":Institution"), then the request will return "0 row" which is not a boolean
> value.
>
> So the bug is that "return count(n) > 0" is ignored when there is no node
> returned.
>
> Some help would be really appreciated as I don't know how to solve my
> original issue involving the "exists" function.
>
> Thanks,
> Grégoire
>
> Le mercredi 5 mars 2014 16:27:48 UTC+1, Grégoire Colbert a écrit :
> Hi,
>
> I have an abstract class "OrganisationNode" containing a "@GraphId id" field.
>
> I have several concrete classes extending OrganisationNode, for example
> "InstitutionNode" or "CommunityNode". None of them have a @GraphId field. If
> I put another "@GraphId id" field on InstitutionNode, I get the following
> error "Attempt to add id property private java.lang.Long
> eu.ueb.acem.domain.beans.rouge.neo4j.OrganisationNode.id but already have
> property private java.lang.Long
> eu.ueb.acem.domain.beans.rouge.neo4j.InstitutionNode.id registered as id.
> Check your mapping configuration!"
>
> However, this seems ok at first, because each of my DAOs (e.g.
> InstitutionDAO, CommunityDAO, etc) contain a CrudRepository instance specific
> to a given concrete class. It can create nodes and they have the good labels,
> e.g. if I call InstitutionRepository.create("my new institution"), the
> resulting node will have the labels : "Organisation", "Institution" and
> "_Institution". That's exactly what I want.
>
> The problem is that CrudRepository#exists returns true, even if I mix the
> concrete classes. For example, if I call InstitutionRepository#exists(id of a
> CommunityNode), it returns true! The same thing happens with
> CommunityRepository#exists(id of an InstitutionNode).
>
> It seems that the @GraphId concerns the OrganisationNode and that the
> "exists" method doesn't care about the type associated with the
> CrudRepository. I would find logical the following results :
> - InstitutionRepository#exists(id of a InstitutionNode) to return true
> - InstitutionRepository#exists(id of a CommunityNode) to return false
>
> Is that a bug? Or is that how it is supposed to work, and should I overwrite
> the "exists" method?
>
> Thanks!
>
> Grégoire
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.