简体   繁体   中英

doctrine:mapping:import from existing oracle database not possible

I'm using an oracle db 12c with a table "data.account", "data.users" and "data.service". I've created a separate user "api" with "select" permissions on these tables.

Then i've created a new symfony flex skeleton and added further requirements:

  "require": {
    "php": "^7.1.3",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "sensio/framework-extra-bundle": "^5.4",
    "sensiolabs/security-checker": "^6.0",
    "symfony/apache-pack": "^1.0",
    "symfony/cache": "4.3.*",
    "symfony/console": "4.3.*",
    "symfony/dotenv": "4.3.*",
    "symfony/flex": "^1.3.1",
    "symfony/framework-bundle": "4.3.*",
    "symfony/monolog-bundle": "^3.4",
    "symfony/orm-pack": "^1.0",
    "symfony/security-core": "4.3.*",
    "symfony/twig-bundle": "4.3.*",
    "symfony/webpack-encore-bundle": "^1.6",
    "symfony/yaml": "4.3.*",
    "ext-json": "*"
  },
  "require-dev": {
    "symfony/browser-kit": "4.3.*",
    "symfony/css-selector": "4.3.*",
    "symfony/debug-pack": "^1.0",
    "symfony/maker-bundle": "^1.13",
    "symfony/phpunit-bridge": "^4.3",
    "symfony/profiler-pack": "^1.0"
  },

After this was the perfect time to test if the db connection is working:

php bin/console doctrine:query:sql "SELECT * FROM data.ACCOUNT FETCH FIRST 1 ROWS ONLY"

Great this returns the expected result. Now i should be able to import these tables and generate entities. So i followed this help-page

So i tried:

php bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity -vvv
Database does not have any mapping information.

Dammit. I've also tried:

php bin/console doctrine:mapping:convert yml "App\Entity" --from-database --force                                                                                                                     
 [OK] No Metadata Classes to process.

My doctrine config:

doctrine:
  dbal:
    charset: UTF8
    logging: "%kernel.debug%"
    profiling: "%kernel.debug%"
    url: '%env(resolve:DATABASE_URL)%'
  orm:
    auto_generate_proxy_classes: true
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true
    mappings:
      App:
        is_bundle: false
        type: annotation
        dir: '%kernel.project_dir%/src/Entity'
        prefix: 'App\Entity'
        alias: App

.env:

DATABASE_URL=oci8://user:pass@host:1522/dev

I've retried after deleting the cache with "php bin/console c:c" and even deleted the whole folder, but still its not working.

Thanks to @emix, we've narrowed the problem. After clearing the logs and retry i can see the following:

[2019-08-26 11:23:35] doctrine.DEBUG: SELECT * FROM sys.user_tables [] []

So now i know that doctrine is trying to locate the currently owned tables from the user. But the data.ACCOUNT table lies in another schema and the table was granted "select". This table is not owned by this user.

So how can i tell doctrine to look into another schema for the granted tables?

I think the main problem is Oracle likes to name tables and columns in upper case. So if you have a table in lower case Oracle will quote it and en ENtity with the name "entity".php is quite difficult!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM