16 ms·
To me the biggest benefit of ActiveRecord is the database introspection to dynamically create the objects attributes based on the columns in the database. This
by seasoup 16y ago
To me the biggest benefit of ActiveRecord is the database introspection to dynamically create the objects attributes based on the columns in the database.
This doesn't do that in Java, it parses rails migrations to generate the java classes for objects with these attributes.
Why is this a problem?
We have a similar setup up where I work, but rails migrations doesn't manage the database schema, that is managed on the java side. Rails still gets all changes to the DB in its objects, but using this setup wouldn't work. I was all excited by the title too, still it's a good solution to their particular problem.
- Stormbringer 16y agoI remember tackling a similar database introspection problem in 2006 I think it was. Reflection played a pretty big part in the solution if I recall. I don't remember what exactly it was that I wanted to do, but it might have been something like building a dynamic table editor. You pull back the resultset, and then whip up a grid and for each column you assign the column heading based on the value from the resultset, and then when you go to update one of the rows you need to remember the name of the column for building the query dynamically. You have to jump through a few hoops, but it isn't hard. Anyway, once I discovered the superior technology of JPA I never looked back.
- electrum 16y agoIt doesn't use the Rails migrations -- it reads the schema from schema.rb, which is generated by `rake db:schema`. You usually don't run this directly as it happens whenever you run `rake db:migrate`, but it's not dependent on migrations.