Thanks to visit codestin.com
Credit goes to github.com

Skip to content

@Indices is not neccessary to use, multiple @Index annotations on class are allowed #948

@Dacesilian

Description

@Dacesilian

I think you can modify example in https://nitrite.dizitart.com/java-sdk/repository/entity/index.html#indices to not use wrapper @indices. I've looked into code and I think you load @Index annotations with and without @indices, so no code should is needed.

SonarLint:

Before Java 8, a container annotation was required as wrapper to use multiple instances of the same annotation. As of Java 8, this is no longer necessary. Instead, these annotations should be used directly without a wrapper, resulting in cleaner and more readable code.

This:

@Indices({
        @Index(fields = "id", type = IndexType.UNIQUE),
        @Index(fields = "partNumber", type = IndexType.UNIQUE),
})
public class MyClass implements Serializable

can be replaced with:

@Index(fields = "id", type = IndexType.UNIQUE)
@Index(fields = "partNumber", type = IndexType.UNIQUE)
public class MyClass implements Serializable

https://docs.oracle.com/javase/tutorial/java/annotations/repeating.html

Metadata

Metadata

Assignees

Labels

javaPull requests that update Java code

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions