users@glassfish.java.net

Re: persist entities across different databases

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Wed, 11 Apr 2007 02:37:09 +0200

Do you want to create two separate databases, where tables from first
database are using foreign keys referencing tables in secound database
and vice versa?
Are you sure you want something like this?
If so, you could try using explicit annotations or xml describing
columns' (or tables') DDL manually, but... well... I am not sure if
TopLink would be able to understand it. It would have to manage two
databases using separate persistence units, but it would have to
combine those two when creating cross-database query for example.
Maybe you could use single persistence unit and provide table names to
entities mappings manually, using DB-vendor specific prefixes, like
this:
"database1", table: "companies"
"database2". table: "workers"
@Entity Companies, tableName="database1$companies"
@Entity Workers, tableName="database2$workers"

but I am only guessing... For sure, database1 and database2 would have
to act as one database with special table names, but what about
username/password? One PersistenceUnit can use only one
username/password, you cannot assign username per table in JPA...
But I am not an expert, I am curious what experts would say.


2007/4/11, glassfish_at_javadesktop.org <glassfish_at_javadesktop.org>:
> Hi marina
>
> thanks for your clear answer.
> My question was related about relationships between entities stored in different databases.
> e.g
> Entity stored in database APP
> class A
> private B;
>
> Entity stored in database COMMON
> class B
>
> As this is beyond the spec as you stated, does Toplink supports this type of mapping?
> Regards
> Yves.
> [Message sent by forum member 'ygillet' (ygillet)]
>
> http://forums.java.net/jive/thread.jspa?messageID=211749
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>