[odb-users] Re: specifying column and table names for many-to-many join tables

Matt Walker leafless.matt at gmail.com
Mon Oct 3 17:14:39 EDT 2016


Ok, I played with the xx_column pragmas and field name and got it to
generate DDL that looked like what I'm dealing with. In case any one finds
it helpful...

use:

class UserProfile {....};

class AppUser {
....
#pragma db value_column("*USER_PROFILE_ID*") id_column("*USER_ID*")
   vector<shared_ptr<UserProfile>> *USER_PROFILE*_;
};

generates:


CREATE TABLE `APP_USER_USER_PROFILE` (
  `USER_ID` INT(11) NOT NULL,
  `USER_PROFILE_ID` INT(11) NOT NULL,
  CONSTRAINT `APP_USER_USER_PROFILE_USER_ID_fk`
    FOREIGN KEY (`USER_ID`)
    REFERENCES `APP_USER` (`id`)
    ON DELETE CASCADE
  /*
  CONSTRAINT `APP_USER_USER_PROFILE_USER_PROFILE_ID_fk`
    FOREIGN KEY (`USER_PROFILE_ID`)
    REFERENCES `USER_PROFILE` (`id`)
  */)
 ENGINE=InnoDB;


On Mon, Oct 3, 2016 at 3:37 PM, Matt Walker <leafless.matt at gmail.com> wrote:

> I am dealing with an existing schema, so I cannot use ODB to generate the
> sql. I have looked at the documentaion and don't see any way to specify the
> particulars with pragmas. E.G., Hibernate allows you to annotate a field in
> an entity with the name of the join table and column. Is this possible?
>
> Thanks,
>
> Matt Walker
>


More information about the odb-users mailing list