If you use Eclipselink you can add this import to your class:
import org.eclipse.persistence.annotations.Index;
Then add your @Index to your field like this:
public class FooClass {
@Index
int field1;
}
or
@Index(columnNames = {"field1", "field2"})
public class FooClass {
int field1;
int field2;
}