Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

putNoOverwrite dirties a secondary index

690755Nov 6 2009 — edited Nov 10 2009
Context: BDB v4.7.25, DPL through the Java API, replication subsystem enabled (thus with transactions, logging, etc.)

I encounter a strange behavior using putNoOverwrite on an existing entity with secondary keys.
One of the two secondary indexes declared in the entity gets broken.

Let me explain the case with an example.

The entity :
@Entity(version=0)
public class SomeEntity
{
@PrimaryKey
private int pk;

@SecondaryKey(relate=Relationship.MANY_TO_ONE, relatedEntity=AnotherEntity.class, onRelatedEntityDelete=DeleteAction.ABORT)
private int fk;

@SecondaryKey(relate=Relationship.MANY_TO_ONE)
private String state = "UNKNOWN";
}

The first put or putNoOverwrite is perfect:
putNoOverwrite(pk = 1, fk = 10, state = "OK")

My entity is present in DB, I can retrieve it through the secondary database "state" with the value "OK" (method SecondaryIndex.subIndex).

Then the faulty putNoOverwrite:
putNoOverwrite(pk = 1, fk = 10, state = "UNKNOWN")

This call should have no effect. In turn, my entity is still present in DB, and when I retrieve through is PK, I get it untouched.
But when I retrieve it through the secondary index "state" with value "OK" (method SecondaryIndex.subIndex), there is no match. The only secondary key present in the secondary index is "UNKNOWN".

I encounter this issue repeatedly.
Thanks for your help
This post has been answered by 645330 on Nov 6 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2009
Added on Nov 6 2009
2 comments
1,973 views