Thread: SecondaryIndex does not work when SecondaryKey is added to a subclass


Permlink Replies: 2 - Pages: 1 - Last Post: Jun 10, 2008 2:44 PM Last Post By: greybird
Stan L.

Posts: 3
Registered: 05/28/08
SecondaryIndex does not work when SecondaryKey is added to a subclass
Posted: Jun 6, 2008 10:05 AM
Click to report abuse...   Click to reply to this thread Reply
When I add new SecondaryKey to an entity class JE makes me update its version number. I can, however, add a SecondaryKey to a persistent subclass without updating entity version. The only thing I have to do is update version of persistent subclass itself. For example, if I have an entity class

====
import com.sleepycat.persist.model.*;
import java.util.*;

@Entity
public class NodeBase
{
@PrimaryKey(sequence="NodeId")
public int id;

@Override
public String toString()
{
return "node #" + id;
}
}
====

and its subclass evolves from

====
import com.sleepycat.persist.model.*;
import java.util.*;

@Persistent(version=0)
public class DerivedNode extends NodeBase
{
public Collection<Integer> neighbors = new TreeSet<Integer>();

@Override
public String toString()
{
return super.toString() + " connected to " + neighbors;
}
}
====

to

====
import com.sleepycat.persist.model.*;
import java.util.*;

@Persistent(version=1)
public class DerivedNode extends NodeBase
{
@SecondaryKey(relate=Relationship.MANY_TO_MANY,relatedEntity=NodeBase.class)
public Collection<Integer> neighbors = new TreeSet<Integer>();

@Override
public String toString()
{
return super.toString() + " connected to " + neighbors;
}
}
====

The new index "neighbors" remains empty when I add instances of DerivedNode with non-empty neighbors collection. It will only start working when I update version of NodeBase.

It seems that all index information is maintained within entity definition, regardless of where indexes are defined in its class hierarchy. JE does not enforce entity version number updates when such indexes are added. Is that done by design?

I tested this with je-3.2.76 using JDK 1.5 on Windows XP.
greybird

Posts: 1,296
Registered: 07/13/06
Re: SecondaryIndex does not work when SecondaryKey is added to a subclass
Posted: Jun 8, 2008 5:34 PM   in response to: Stan L. in response to: Stan L.
Click to report abuse...   Click to reply to this thread Reply
Hi Stan,

I don't have a complete resolution for this problem but I wanted to let you know that we're working on it and are able to reproduce it. It is a JE bug -- this behavior is not intentional. I will let you know as soon as we have a full resolution, which should be in the next several days.

Thanks for reporting this.

--mark
greybird

Posts: 1,296
Registered: 07/13/06
Re: SecondaryIndex does not work when SecondaryKey is added to a subclass
Posted: Jun 10, 2008 2:44 PM   in response to: greybird in response to: greybird
Click to report abuse...   Click to reply to this thread Reply
Another update: I have identified the problem internally and confirmed that bumping the version of the Entity class is a safe workaround.

The fix is still to come, but the workaround is safe.

--mark
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums