Search code examples
activejdbc

Is there any way to specify table prefixes in ActiveJDBC models?


Is there any way to change the table name of the models, or specify a table prefix, so that the model named People, for example, would reference the table TP_PEOPLE?


Solution

  • There is a way, you can use the @Table annotation, such as:

    @Table("TP_PEOPLE")
    public class People extends Model {}
    

    however, I would suggest to call your class Person, since the instance of this class represent a single row from your table:

    @Table("TP_PEOPLE")
    public class Person extends Model {}
    

    so that your code will look:

    List<Person> people = Person.where("ssn  = ?", ssn);