ObjectDB ObjectDB

Problem witch CriteriaBuilder isMember(..)

#1

Dear Objectdb-Team

I have some Problems running a criteria query against a set. But maybe I misunderstood some essentials

I have defined an entity class and an embeddable class like this

@Entity
class Container {
    @ElementCollection(fetch = FetchType.EAGER)
    List<Testclass>  testlist1 = new LinkedList<Testclass>();
    @ElementCollection(fetch = FetchType.EAGER)
    List<String>      testlist2 = new LinkedList<String>();
    Testclass    testobject = new Testclass(0,0);
}

@Embeddable
class Testclass {
    long uid = 0;
    long udb = 0;
}


Im unable to search for some occurence of Objects of Testclass in Container (equal and hash methods in Testclass are implemented). My problem is, that

CriteriaBuilder cb = ...
Root<Container> root = ...

Testclass searchobject = new Testclass(1,2);
Predicate predicate = cb.isMember(searchobject,root.<Collection<Testclass>>get("testlist1"));

doesn't work, while

String searchobject = "testtext";
Predicate predicate = cb.isMember(searchobject,root.<Collection<String>>get("testlist2"));

works as expected.

the equal-query

Testclass searchobject = new Testclass(1,2);
Predicate predicate = cb.equal(a_root.<Testclass>get("testobject"), searchobject);

works as expected.

Even the cb.in(..) method works as expected. Is this a problem of objectdb or does the isMember(..) Method could not be used on user defined classes or does i missed some extra configuration.

edit
delete
#2

Thank you for your report.

Please try build 2.6.4_08 which fixes an issue of using MEMBER with embedded objects.

ObjectDB Support
edit
delete
#3

great, it works :-)

I have to admit your support is really excellent.

best regards

Arne

edit
delete
#4

Sorry for bothering you again ...

until version 2.6.3_07 the equal query works fine (and the isMember doesn't work)

Testclass searchobject = new Testclass(1,2);
Predicate predicate = cb.equal(a_root.<Testclass>get("testobject"), searchobject);

Since version 2.6.3_08 the isMember method works fine and the equal method runs red in our Unit-Test wich means, the container-object is unlocated (but is located in 2.6.3._07).

best regards

Arne

 

edit
delete
#5

Is it 2.6.3_07 and 2.6.3_08 or 2.6.4_07 and 2.6.4_08?

ObjectDB Support
edit
delete
#6

sorry my fault,
the correct version numbers are  2.6.4_07 and 2.6.4_08

edit
delete
#7

Unfortunately the repair of build 2.6.4_08 was bad. Build 2.6.4_09 includes another attempt.

ObjectDB Support
edit
delete
#8

I really feel sorry but I have to bother again.

Until build 2.6.4_09 the isMember method works fine with embeddable objects. But in 2.6.5_02 and 2.6.5_03 its broken again. Even worse the 

criteriabuilder.equal(root.<Testclass>get("testmember"), new Testclass(1,2));

doesn't work for me (as it do in 2.6.4_09). For now I switch back to 2.6.4_09. 

best regards

Arne

 

PS.: maybe I should make clear, that Testclass uses its own equal and hash methods (generated from Eclipse)

PPS.: I recognized another problem (in 2.6.4_09) with the criteriabuilder.in(..) method. This method delivers wrong results, if there is a query against a list, wich has different members, but the same size. 

List<Testclass> uid1_list = .. new Testclass(1,1), new Testclass(2,1)
List<Testclass> uid2_list = .. new Testclass(1,99), new Testclass(2,99)
List<Testclass> uid3_list = .. new Testclass(1,99), new Testclass(2,99), new Testclass(3,99)
Predicate test_predicate =  expression.in(uid1_list); // works fine
Predicate test_predicate =  expression.in(uid2_list); // fails, only if running after uid1_list
Predicate test_predicate =  expression.in(uid3_list); // works fine as long there is no previous
                                                         list the size of 3

 

To avoid this behavior (of the criteria builder.in method), you can set the attribute 'programs' to zero. If you do so, query against all lists works fine. 

<query-cache results="32mb" programs="0" />

 

 

edit
delete
#9

Thank you for this report. Please check Build 2.6.5_04 that should fix both issues.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.