HiberObjects

Download

Order

Forum

Vote for this plugin

Configuring the Import

Let's have a look at one table that we are very interested in: phpbb_users.

The Total Result is not exactly what we want; The class name becomes PhpbbUsers. I want it to be User. It's obviously the className method we need to change. I try to modify it and push Update Method, and what do you know! Much better!

The columns username and user_password seem ok, but why not remove the prefix "user_" from these variables? I modify the variableName method and push Update Method:

That seems to work. (The multiple @Column annotations will be joined in the final code.)

Import Associations by Name

Let's look at the other columns. group_id is interesting. This is a reference to phpbb_group, but it will be imported as int group;

Wouldn't it be much better if this column was imported as an association? HiberObjects will do that based on foreign keys, but in this case, there is no foreign key. HiberObjects can also import associations based on column names, so group_id in table phpbb_users should be handled as a referenced to phpbb_groups, because group_id is the primary key of phpbb_groups.

The problem now is the warning we got from the findPrimaryKeys method earlier:

group_id is PK in phpbb_extension_groups, phpbb_groups

So, HiberObjects doesn't know which of these tables to use.

We may modify the findPrimaryKeys method to let group_id always point to phpbb_groups, but in this case we decide to do it only for the phpbb_users table. Edit the getReferencedTable method, push Update Method and look at the Total Result. We will now get a one-to-many association between Users and Groups.

Next: The Result