MySQL Forums
Forum List  »  NDB clusters

ClusterJ ordering bug?
Posted by: Audrius Valunas
Date: October 05, 2017 11:37PM

Anyone encountered and now root cause for problem when you can either setordering or use query filter but not both because otherwise code fails with "There is no index containing the ordering fields" ? Details below.


Table definition:
CREATE TABLE `game` (
id bigint not null auto_increment primary key,
room int not null,
round bigint not null,
stage int not null,
cards varchar(32) default '',
odds varchar(32) not null,
outcome varchar (16) default null,
time timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
KEY idx_game (room, round)
) ENGINE=ndbcluster;

Entity:
@PersistenceCapable(table = "game")
@Indices({ @Index(name = "idx_game")})
public interface GameEntity {
@PrimaryKey
long getId();
void setId(long id);
@Column(name = "round")
long getRoundId();
void setRoundId(long id);
@Column(name = "room")
int getRoomId();
void setRoomId(int id);
String getCards();
void setCards(String cards);
void setOdds(String odds);
String getOdds();
int getStage();
void setStage(int stage);
String getOutcome();
void setOutcome(String finished);
Date getTime();
void setTime(Date time);
}

This one works:
QueryDomainType<GameEntity> qdg = session.getQueryBuilder().createQueryDefinition(GameEntity.class);
Query<GameEntity> queryGame = session.createQuery(qdg);

queryGame.setOrdering(Ordering.DESCENDING, "id");
queryGame.setLimits(0, 1);
List<GameEntity> gs = queryGame.getResultList();
return gs.isEmpty() ? -1 : gs.get(0).getId();

And this one fails with "There is no index containing the ordering fields":
QueryDomainType<GameEntity> qdg = session.getQueryBuilder().createQueryDefinition(GameEntity.class);
qdg.where(qdg.get(OUTCOME).isNotNull());
Query<GameEntity> queryGame = session.createQuery(qdg);

queryGame.setOrdering(Ordering.DESCENDING, "id");
queryGame.setLimits(0, 10);
return queryGame.getResultList());

Although there is no difference in ordering only the query filtering is added.

Options: ReplyQuote


Subject
Views
Written By
Posted
ClusterJ ordering bug?
866
October 05, 2017 11:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.