New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child Object Join issue #54

Closed
ggunders opened this Issue Jul 21, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@ggunders

ggunders commented Jul 21, 2015

I have a odd issue that i am not understanding.

Due to the sensitivities of the project, i have written an example of the issue as to not provide an abundance of code.

@RushTableAnnotation
public class Human extends RushObject {

String name;
String eyeColor;
Pet pet1;
Pet pet2;

public Human(){}
 getters and setters and toString

@RushTableAnnotation
public class Pet extends RushObject {
String name;
String type;

public Pet(){}

getters and setters and toString

Pet is a child of parent Human

Main:

  RushCore.getInstance().deleteAll(Human.class);
   RushCore.getInstance().deleteAll(Pet.class);


    Pet p1 = new Pet();
    p1.setName("ruby");
    p1.setType("Cat");


    Pet p2 = new Pet();
    p2.setName("jordan");
    p2.setType("Dog");


    Human h1 = new Human();
    h1.setName("Fred");
    h1.setEyeColor("blue");
    h1.setPet1(p1);
    h1.setPet2(p2);

    h1.save();
    System.out.println(h1.toString());

    Pet p3 = new Pet();
    p3.setName("fluffy");
    p3.setType("Cat");


    Pet p4 = new Pet();
    p4.setName("spike");
    p4.setType("Dog");


    Human h2 = new Human();
    h2.setName("Barney");
    h2.setEyeColor("green");
    h2.setPet1(p3);
    h2.setPet2(p4);


    h2.save();
    System.out.println(h2.toString());
    List<Human> humans = new RushSearch().find(Human.class);
    System.out.println(humans.toString());
    // now retrieve a pet and assign to a new person

    Pet p5 = new RushSearch().whereEqual("name", "ruby").findSingle(Pet.class);
    System.out.println(p5.toString());

    Pet p6 = new RushSearch().whereEqual("name", "jordan").findSingle(Pet.class);
    System.out.println(p6.toString());

    Human h3 = new Human();
    h3.setName("Betty");
    h3.setEyeColor("brown");
    h3.setPet1(p5);  // this works
    h3.setPet2(p6);  // this works

    h3.save();
    List<Human> humans1 = new RushSearch().find(Human.class);
    System.out.println(humans1.toString());

this works as expected. But lets say i swap the pet assignments of p5, p6

so:
Human h3 = new Human();
h3.setName("Betty");
h3.setEyeColor("brown");
h3.setPet1(p6); // no work == null
h3.setPet2(p5); // works
h3.save();
List humans1 = new RushSearch().find(Human.class);

when i swap p5 and p6, the child object of h3 is null. after looking at the sqlite tables, i dont see anything wrong. the pet, human, and join tables have the correct relationships. but when i retrieve the humans i get null for pet1 on h1 and h3.

here is the screen dump for stdout

I/System.out﹕ human{name='Fred', eyeColor='blue', pet1=Pet{name='ruby', type='Cat'}, pet2=Pet{name='jordan', type='Dog'}}
System.out﹕ human{name='Barney', eyeColor='green', pet1=Pet{name='fluffy', type='Cat'}, pet2=Pet{name='spike', type='Dog'}}
System.out﹕ [human{name='Fred', eyeColor='blue', pet1=Pet{name='ruby', type='Cat'}, pet2=Pet{name='jordan', type='Dog'}}, human{name='Barney', eyeColor='green', pet1=Pet{name='fluffy', type='Cat'}, pet2=Pet{name='spike', type='Dog'}}]
System.out﹕ Pet{name='ruby', type='Cat'}
System.out﹕ Pet{name='jordan', type='Dog'}
System.out﹕ [human{name='Fred', eyeColor='blue', pet1=null, pet2=Pet{name='jordan', type='Dog'}}, human{name='Barney', eyeColor='green', pet1=Pet{name='fluffy', type='Cat'}, pet2=Pet{name='spike', type='Dog'}}, human{name='Betty', eyeColor='brown', pet1=null, pet2=Pet{name='ruby', type='Cat'}}]

Notice all the child pets get assigned correctly until i assign h3 pets from pets assigned to h1, but only in a specific order.

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell Jul 23, 2015

Owner

Hi sorry for the delayed response, I will unit test it and give you a sold answer/fix asap.

Thanks

Owner

Stuart-campbell commented Jul 23, 2015

Hi sorry for the delayed response, I will unit test it and give you a sold answer/fix asap.

Thanks

@ggunders

This comment has been minimized.

Show comment
Hide comment
@ggunders

ggunders Jul 31, 2015

This bug is a serious issue for us. Parent object with multiple children objects of the same type are coming back as null when saved and subsequently searched.

ggunders commented Jul 31, 2015

This bug is a serious issue for us. Parent object with multiple children objects of the same type are coming back as null when saved and subsequently searched.

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell Aug 4, 2015

Owner

Fixed v1.0.8

Owner

Stuart-campbell commented Aug 4, 2015

Fixed v1.0.8

@ggunders

This comment has been minimized.

Show comment
Hide comment
@ggunders

ggunders Aug 4, 2015

got to test this really quickly. so far its good! ill keep testing. thanks so much for the quick turn around.

ggunders commented Aug 4, 2015

got to test this really quickly. so far its good! ill keep testing. thanks so much for the quick turn around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment