In OrmLite the name of a table is either the name of the class it is based on or whatever is defined in @DatabaseTable(tableName = "...")
annotating that class.
Is there a convenient way to get the name of a table at runtime? In my case I need the name of all tables when upgrading the database to recreate database triggers based on those tables.
I already checked http://ormlite.com/javadoc/ormlite-core/com/j256/ormlite/table/TableInfo.html but I don't understand what the ID is supposed to be.
You could use the extractTableName
method from the DatabaseTableConfig
class.
Extract and return the table name for a class.
public class Test {
public static void main(String[] args){
String name = DatabaseTableConfig.extractTableName(A.class);
System.out.println(name); //TableA
}
}
@DatabaseTable(tableName="TableA")
class A {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With