Announcement Announcement Module
Collapse
No announcement yet.
Neo4j - findByPropertyValue getting null after successful update/persist Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neo4j - findByPropertyValue getting null after successful update/persist

    I have simple domain with id as long (and couple of string variables as well), it is annotated with @Indexed. Able to persist and retrieve it back using findByPropertyValue method. After 2nd update/persist, i am getting null from findByPropertyValue method when i trying to retrieve it by using id. Strangely i couldn't able to reproduce same behavior from junit unit-testing. Any help appreciated.

    Preet.

  • #2
    Preet,

    thanks for the pointer. I'll look into it. Could you raise an issue at http://spring.neo4j.org/issues ?

    And provide the code for your domain object + lookup code.

    Thanks a lot

    Michael

    Comment


    • #3
      Thanks for the reply Michael.

      And sorry for the delayed reply, i was burned down with STS upgrade and it was mess. I had to roll back to 2.6 version.

      Anyways, the problem with findByPropertyValue getting null when used with Named indexed field is NO index document created, when i looked at indexes with Luke tool http://code.google.com/p/luke/, it seems like happening intermittently,

      Am i doing something wrong? BTW field type is java long.

      -Preet.

      Comment


      • #4
        Preet,

        could you provide the code that causes the error?

        Thanks a lot

        Michael

        Comment


        • #5
          Here is the code, cleaned up for clarity, it was basic lookup...
          Code:
          ===========domain================
          
          @NodeEntity
          public class MEvent {
          
          
              @Indexed(indexType=IndexType.FULLTEXT, indexName = "event_id_search")
          	protected long id;
          	private short version;
          	private long lastModifiedAsLong; 
          	@Indexed
          	private long dateCreatedAsLong;
              
          	public long getId() {
          		return id;
          	}
          
          	public void setId(long id) {
          		this.id = id;
          	}
          
          	private void init(){
          	//	dataMode = EventDataMode.INIT;
          	//	setId(Utils.getNxtId());
          	//	setVersion((short)1);
          	//	setDateCreatedAsLong(Utils.getUnxSeq());
          	}
              
          	public short getVersion() {
          		return version;
          	}
          
          	public void setVersion(short s) {
          		this.version = s;
          	}
          
          	public void setDateCreatedAsLong(long dateCreatedAsLong) {
          		this.dateCreatedAsLong = dateCreatedAsLong;
          	}
          
          	public long getDateCreatedAsLong() {
          		return dateCreatedAsLong;
          	} 
          	//--constructors
              public MEvent() {
              }
          
              public MEvent(String title) {
                  init();
                  this.title = title;
              }
          
          }
          
          =============repo
          public interface EventRepository extends GraphRepository<MEvent>, NamedIndexRepository<MEvent> {
          }
          
          ===============service
          
          @Repository
          @Transactional
          public class EventService {
          
              @Autowired private EventRepository eventRepository;
              private static final Logger log = LoggerFactory.getLogger(EventService.class);
             
              public MEvent getEvent(long id) {
                  return eventRepository.findByPropertyValue("event_id_search","id",id );
              }
          }
          Last edited by MichaelHunger; Mar 10th, 2012, 07:16 AM. Reason: code tags

          Comment


          • #6
            Please don't do a fulltext index on a numeric id, it doesn't make sense anyway. Please remove indexType=IndexType.FULLTEXT,

            Michael

            Comment


            • #7
              You are right, initially i wasn't doing fulltext on long id, but i tried fulltext search, to see if it makes any difference. Either way not much difference.

              Comment


              • #8
                Does it really make any difference of using long vs Long (object) in using indexing (using lucene)?

                Comment


                • #9
                  long should be converted into Long anyway.
                  But that is a good point, does it also fail on dateCreatedAsLong ?

                  Comment


                  • #10
                    Thanks Michael, I think i found the problem. I am using UUID as lookup id, which i am setting it in constructor, which uses setId accessor method. Somehow setId called twice via AspectJ introduced methods, this is my guess. When i moved setId out of constructor i see expected behavior.

                    Comment

                    Working...
                    X