Reputation: 30107
If understood correctly, ActiveJdbc
compiler should take as input hollow class like this
public class Employee extends Model {}
and fill it with some code from database metadata.
But how can it know where database is located?
I found only one place here http://javalite.io/getting_started where database is mentionned, namely
Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test", "user1", "xxxxx");
So, does instrumentation compiler scans code for calls to Base.open()
and parses it for URL?
I can't believe it. What if there are multiple calls to different databases?
What if there is no Base.open()
call?
Upvotes: 2
Views: 782
Reputation: 10968
Looking at the activejdbc-instrumentation source, what is does basically is:
org.javalite.activejdbc.Model
and for each class
org.javalite.activejdbc.Model
, which include:
public static MetaModel getMetaModel()
public static List<String> attributes()
public static List<Association> associations()
public static int delete(String query, Object... params)
public static boolean exists(Object id)
public static int deleteAll()
public static int update(String updates, String conditions, Object ... params)
public static int updateAll(String updates, Object ... params)
public static String getClassName()
method that returns the fully-qualified name of the class.activejdbc_models.properties
file containing model.getName() + ":" + getDatabaseName(model) + "\n"
, where the first method returns the fully-qualified name of the class, and the second method returns the value of the @DbName
annotation on the class or "default"
if no annotation is found.All database metadata is resolved in runtime, not during compilation or instrumentation phase.
Upvotes: 2