简体   繁体   English

不同数据库中的两个表的关系存在问题,ActiveJDBC 是如何工作的?

[英]There is problem with relationship about two table in different DB, how works ActiveJDBC?

I have this problem:我有这个问题:

TABLE_1 -> db A TABLE_1 -> 分贝 A

TABLE_2 -> db B TABLE_2 -> 分贝 B

fields TABLE_1:字段表_1:

  • id_PK, id_PK,
  • id_table_2_FK, id_table_2_FK,
  • description描述

fields TABLE_2:字段表_2:

  • id_PK id_PK
  • description描述

Relationship : TABLE_1 belongs to TABLE_2 foreignKeyName id_table_2_FK关系:TABLE_1 属于 TABLE_2 foreignKeyName id_table_2_FK

CASE 1:情况1:

  1. step 1: start application第一步:开始申请
  2. step 2: i try query find from TABLE_2 and it works第 2 步:我尝试从 TABLE_2 查询查找,它可以工作
  3. step 3: i try query find from TABLE_1 and it works第 3 步:我尝试从 TABLE_1 查询查找,它可以工作

CASE 2:案例二:

  1. step 1: start application第一步:开始申请
  2. step 2: i try query find from TABLE_1 and follow exception:第 2 步:我尝试从 TABLE_1 查询查找并遵循异常:

    java.lang.NullPointerException java.lang.NullPointerException

     at org.javalite.activejdbc.Registry.processOverridesBelongsTo(Registry.java:393) at org.javalite.activejdbc.Registry.processOverrides(Registry.java:283) at org.javalite.activejdbc.Registry.init(Registry.java:138)... 127 more

and when set LOG properties about activejdbc, follow this,当设置关于activejdbc的LOG属性时,遵循这个,

java.lang.NoClassDefFoundError: Could not initialize class org.javalite.activejdbc.Registry
    at org.javalite.activejdbc.ModelDelegate.metaModelOf(ModelDelegate.java:279) 
  1. step 3: i try query find from TABLE_2 and it works第 3 步:我尝试从 TABLE_2 查询查找,它可以工作
  2. step 4: i try query find from TABLE_1 and it works第 4 步:我尝试从 TABLE_1 查询查找,它可以工作

As seen in CASE 2, in step 2, the query don't work, BUT in step 4 all works, what's wrong?如案例 2 所示,在第 2 步中,查询不起作用,但在第 4 步中一切正常,有什么问题?

Thank you for all...感谢你所做的一切...


UPDATE:更新:

I see that org.javalite.activejdbc.我看到了 org.javalite.activejdbc。 Registry , in CASE 2 don't configure correctly the relationship with TABLE_1 (table1Model) and TABLE_2(table2Model); Registry ,在 CASE 2 中没有正确配置与 TABLE_1 (table1Model) 和 TABLE_2(table2Model) 的关系; but, as you can see in CASE 1, if i call first db A(table1Model) and after db B(table2Model) Registry class configure correctly the relationship with two different model.但是,正如您在案例 1 中看到的那样,如果我调用第一个 db A(table1Model) 并在 db B(table2Model) Registry class 之后调用两个不同的 model 的关系。

I have configure ApplicationFilter, in my spring boot application, that override init, doFilter and destroy method;我在 spring 启动应用程序中配置了 ApplicationFilter,它覆盖了 init、doFilter 和 destroy 方法; someone know if is possible configure Registry.class, with db A and B relationship, in init method?有人知道是否可以在初始化方法中配置 Registry.class,具有 db A 和 B 关系?

JavaLite ActiveJDBC is not designed to manage relationships across different schemas. JavaLite ActiveJDBC 并非旨在管理跨不同模式的关系。 If you have anything working in this mode, it is purely coincidental.如果您有任何东西在这种模式下工作,那纯属巧合。

To fully understand your question, we will need:要完全理解您的问题,我们将需要:

  • DDL for tables表的 DDL
  • code that manages your connections to the databases管理您与数据库的连接的代码
  • model source code (not necessarily all, just to see names and other config if present) model 源代码(不一定全部,只是查看名称和其他配置(如果存在))

For information on access to multiple databases, please refer to: https://javalite.io/database_connection_management#multiple-database-example有关访问多个数据库的信息,请参阅: https://javalite.io/database_connection_management#multiple-database-example

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

相关问题 SQL DB表关系 - SQL DB table Relationship 如何在 Power BI 中使用 3 种不同的表关系? - How to use 3 different table relationship in Power BI? 如何将数据插入到与第一个表的未知PK关系的两个表中? - How to insert data to two tables on relationship with unknown PK of first table? 实体框架从两个表关系不同的表中选择主/外键场景 - Entity framework select from two tables with different table relationship primary/foreign key scenarios 更高效的外键关系还是大表(思考问题)? - More Efficient Foreign Key Relationship or Large Table (thinking through the problem)? 如何命名SQL FOREIGN KEY约束,将两个表列创建为关系表 - How to name SQL FOREIGN KEY Constraint on CREATE two tables columns into a relationship TABLE 如何删除 mysql 中两个表之间的关系? - How to drop a relationship between two tables in mysql? Flask SQL 关于 2 个不同模型之间的一对多关系的炼金术问题 - Flask SQL Alchemy question about one-to-many Relationship between 2 different models MySQL一对多的关系。 不同的表,还是PHP处理? - MySQL one-to-many relationship. Different table, or PHP handling? 考虑具有两个外键的一对多或多对多关系的正确方法是什么? - What is the correct way to think about a one-to-many or many-to-many relationship with two foreign keys?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM