简体   繁体   English

学说:映射:无法从现有的 oracle 数据库导入

[英]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".我正在使用带有表“data.account”、“data.users”和“data.service”的 oracle db 12c。 I've created a separate user "api" with "select" permissions on these tables.我在这些表上创建了一个具有“选择”权限的单独用户“api”。

Then i've created a new symfony flex skeleton and added further requirements:然后我创建了一个新的 symfony flex 骨架并添加了进一步的要求:

  "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: .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.我用“php bin/console c:c”删除缓存后重试,甚至删除了整个文件夹,但仍然无法正常工作。

Thanks to @emix, we've narrowed the problem.感谢@emix,我们缩小了问题的范围。 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".但是 data.ACCOUNT 表位于另一个模式中,并且该表被授予“选择”权限。 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.我认为主要的问题是 Oracle 喜欢以大写形式命名表和列。 So if you have a table in lower case Oracle will quote it and en ENtity with the name "entity".php is quite difficult!因此,如果您有一个小写的表,Oracle 会引用它,然后将其命名为“entity”.php 的 ENtity 非常困难!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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