databinder-3 bind auth cookie to ip address
databinder-4 databinder dispatch script should respond to 'stop'
databinder-5 databinder dispatch plain HTTP
databinder-6 Access to QueryPanel
databinder-7 auth components need localizable strings
databinder-8 blob size validation
databinder-9 buildr plugin
databinder-10 DataApplication initialization
databinder-11 please reconsider IDataApplication.isDataBrowserAllowed()
databinder-12 Add target directory to svn.ignore
databinder-15 remove button for IterableEntityView
databinder-16 DataServer path-finding problems
databinder-17 DataBinder-AO hard-codes property names
Created by: zcox
on: 2/27/08
Updated by: zcox
on: 2/29/08
Assigned to:

I've noticed a couple places in the Databinder-AO code where entity property names are hard-coded:

  • DataProfilePanel:51 "passwordHash"
  • DataProfilePanel:34 "roleString"
  • Probably others

EntityManager in ActiveObjects uses TableNameConverter and FieldNameConverter to determine the actual column names that the database uses. For example, I could use this code to configure the EntityManager in my DataApplication subclass to support Rails/CakePHP style naming conventions:


@Override
protected void configureEntityManager(EntityManager manager, Object key)
{
    manager.setTableNameConverter(new PluralizedNameConverter(new UnderscoreTableNameConverter(false)));
    manager.setFieldNameConverter(new UnderscoreFieldNameConverter(false));
}

So table for my User entity looks like this:

users table
* id
* username
* password_hash
* role_string

Those hardcoded field names lead to exceptions like this:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'passwordHash' in 'field list'
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
     at com.mysql.jdbc.Util.getInstance(Util.java:381)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022)
     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
     at net.java.ao.DatabaseProvider.executeInsertReturningKey(DatabaseProvider.java:1798)
     at net.java.ao.DatabaseProvider.insertReturningKey(DatabaseProvider.java:1713)
     at net.java.ao.EntityManager.create(EntityManager.java:406)
     at net.java.ao.EntityManager.create(EntityManager.java:440)
     at net.databinder.components.ao.DataForm.inSubmitTransaction(DataForm.java:28)
databinder-18 NPE trying to sign in as non-existent user
databinder-20 [ActiveObjects] Passing Null Values to DBParam
databinder-21 TextileLabel Fails to Render Valid Markup
databinder-22 [DataStaticService] ensureSession disregards key
databinder-23 arrows in baseball ex
databinder-24 rollbacks should warn
databinder-25 graffiti bad query

Enter new issue

[databinder-17] DataBinder-AO hard-codes property names edit

Comments

Okay. This revealed a larger issue as I hadn’t considered that the field names in the map for entity creation need to match converted table field names. So I’ve added some code to translate between the property map keys (which need to remain camel case for Wicket to find the properties) to a field map that uses whatever the entity manager’s field converter is. Seems to work, please confirm and close if so!

Looks like this one is fixed too. Thanks so much!!!

You are, as they say, the s**t!