0

I have this problem:

TABLE_1 -> db A

TABLE_2 -> db B

fields TABLE_1:

  • id_PK,
  • id_table_2_FK,
  • description

fields TABLE_2:

  • id_PK
  • description

Relationship: TABLE_1 belongs to TABLE_2 foreignKeyName id_table_2_FK

CASE 1:

  1. step 1: start application
  2. step 2: i try query find from TABLE_2 and it works
  3. step 3: i try query find from TABLE_1 and it works

CASE 2:

  1. step 1: start application
  2. step 2: i try query find from TABLE_1 and follow exception:

    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,

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
  2. step 4: i try query find from TABLE_1 and it works

As seen in CASE 2, in step 2, the query don't work, BUT in step 4 all works, what's wrong?

Thank you for all...


UPDATE:

I see that org.javalite.activejdbc.Registry, in CASE 2 don't configure correctly the relationship with TABLE_1 (table1Model) and 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.

I have configure ApplicationFilter, in my spring boot application, that override init, doFilter and destroy method; someone know if is possible configure Registry.class, with db A and B relationship, in init method?

Mattia
  • 13
  • 5
  • are you accessing two different databases? That is are tables physically located in different schemas? – ipolevoy Jun 10 '20 at 19:20
  • @ipolevoy Hi! Yes there is two different databases, A = table_1, B = table_2, then tables are located in different schemas. – Mattia Jun 11 '20 at 08:37
  • @ipolevoy Hi igor, i entered an UPDATE if that help you :) – Mattia Jun 12 '20 at 10:49

1 Answers1

1

JavaLite ActiveJDBC is not designed to manage relationships across different schemas. If you have anything working in this mode, it is purely coincidental.

To fully understand your question, we will need:

  • DDL for tables
  • code that manages your connections to the databases
  • model source code (not necessarily all, just to see names and other config if present)

For information on access to multiple databases, please refer to: https://javalite.io/database_connection_management#multiple-database-example

ipolevoy
  • 5,432
  • 2
  • 31
  • 46