title: How to find nodeRef with Alfresco Java API
body: <p>I would like to get the nodeRef of a stored node in alfresco. I have created a node with Alfresco java API and added a data object as a property of node in one method. Now I want to retrieve this data object from that nodeRef in second method. For this I am trying to get nodeRef of that stored node so I can get property of that object.</p>
  
  <p>My code snippet is as below;</p>
  
  <pre><code>// Methos to set RegisterProperty dataobject in a node as a property of node 
  
  
  public void registerProperty(RegisterProperty registerProperty) {
  
      registry.getAuthenticationService().authenticate("admin", "admin".toCharArray());
  
      /* Create Store */
      StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "myStoreProtocol" + GUID.generate());
      if (!nodeService.exists(storeRef)) {
          nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
      }
      /* Get the root node from which to hang the next level of nodes */
      NodeRef rootNode = nodeService.getRootNode(storeRef);
  
      /*         Create child node              */
      ChildAssociationRef assocRef = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN, QName.createQName("vit-mrms", QName.createValidLocalName("myProperty-assocQName")), ContentModel.TYPE_CMOBJECT);
      NodeRef propertyRef = assocRef.getChildRef();
  
      /*  Store Serialized PropertyRegistration object as a node property  */
      QName myPropertyQname = QName.createQName("vit-mrms", registerProperty.getSurveyNo());
      nodeService.setProperty(propertyRef, myPropertyQname, registerProperty);
  }
  
  
  // Methos to get RegisterProperty dataobject from node.
  
  
  public RegisterProperty getRegisterProperty(String surveyNo) {
      registry.getAuthenticationService().authenticate("admin", "admin".toCharArray());
      QName myPropertyQname = QName.createQName("vit-mrms", surveyNo);
      Serializable property = nodeService.getProperty(NodeRef, myPropertyQname);
  
  // I want to retrieve this NodeRef 
  
      System.out.println("Store property in alfresco " + property.toString());
      return (RegisterProperty) property;
  }
  
  // Data object RegisterProperty is as follow,
  
  public class RegisterProperty implements Serializable{
  
      private String ownerName;
      private String surveyNo;
  
      public String getOwnerName() {
          return ownerName;
      }
  
      public void setOwnerName(String ownerName) {
          this.ownerName = ownerName;
      }
  
      public String getSurveyNo() {
          return surveyNo;
      }
  }
  </code></pre>
  
  <p>Please suggest a way to get NodeRef in getRegisterProperty() method so I can retrieve property from that node as a data object.</p>
  
  <p>I tried  SearchService &amp; nodeService to retrieve this node but didn't work for me.</p>
  
  <hr>
  
  <p>Thank you so much Leonardo for quick reply :) </p>
  
  <p>I didn't understand about property name as myprop in Lucene search query. what it shoud be in my case. While setting property to node I added Qname to nodeService.setProperty() method. is the myproperty same as Qname?</p>
  
  <pre><code>// while creating node set ptoperty
  nodeService.setProperty(rootNodeRef, myQname, registerPropertyDataobject);
  
  // my search query
  ResultSet rs = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "@mynamespace\:myprop:\"" + whateverValue + "\"");
  </code></pre>
  
  <p>Also I am not getting syntax of licene search query.</p>
  
  <blockquote>
    <p>"@mynamespace:myprop:\"" + whateverValue + "\""</p>
  </blockquote>