• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Defining 2 separate databases in persistence.xml

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Suppose I need to define to have 2 separate databases backed on the Oracle: DBCustomers and DBProducts.

In DBCustomers I want to have tables: PersonalData and Orders.
In DBProducts I want to have tables: ProductData and Distribution.

My persistence.xml now:




The problem is that when I run it, both databases have all four tables: PersonalData, Orders, ProductData and Distribution. I want to separate these tables as I described in the beginning of this post.

Is there a way to do that?
 
Ismael Upright
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PS. As you can see, the IP address of host with Oracle is the same for both databases - only user differs. But as far as I know, different users in the Oracle have different schemas.
 
Ismael Upright
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never mind, solved it.

The solution is to put the tag:

<exclude-unlisted-classes>true</exclude-unlisted-classes>

to every persistence unit.


Seems that the default beharior is to take the set all classes from all persistence units, and insert them into all databases. A bit strange default to me...
 
author and cow tipper
Posts: 5001
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the update. Even though it looks like you're having a conversation with yourself, I actually found this interesting.

"When "<exclude-unlisted-classes>true</exclude-unlisted-classes>" is present in "persistence.xml", enclosing jar is not scanned for annotated classes."

 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic