> Can't I use slice framework with databases which not have the same structure ?
Slice assumes that data is horizontally partitioned i.e. as if a huge table is
sliced row-wise and put into many separate databases. But this assumption is
not a hard one. You can use Slice even when the slices do not have the same
schema but it will not be as seamless as in the case of identical schemas.
What Slice can not do is if slice-1 and slice-2 both contains table named 'T'
but these two tables have different structures.
What Slice can do is
1. slice-1: has table T1,T2
slice-2: has Table T2,T3
And T2 in slice1 and slice2 have identical schema.
2. The Java entities C1, C2, C3 maps to T1,T2,T3 respectively
3. Your application targets query as follows
C1: to slice-1
C2: no need to target it will execute in all slices
C3: to slice-2
4. As Jody pointed out, the DistributedPolicy should be such that new C1,C3
instances are stored *only* in slice-1 and slice-3 respectively.
Can't I use slice framework with databases which not have the same structure ?
I have two database with different information and I must to use all these
information ...
How can I make query accross slices ? or accross the two database using openjpa
?
Thanks M. Poddar
Hi,
You can target the query that has Userdb1 to slice ONE only.
Slice, in general, considers that the schema in every slice is identical.
I used Websphere 7.0 ( openjpa 1.2.1 snapshot ) and DB2 UBD 9.1
I want to configure slice describe as follow ( persistence.xml )
<persistence-unit name="persistenceUnit">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>com.ibm.openjpa.slice.test.db1.Userdb1</class>
<class>com.ibm.openjpa.slice.test.db2.Customerdb2</class>
<properties>
<property name="openjpa.BrokerFactory" value="slice" />
<property name="openjpa.slice.Names" value="ONE,TWO"/>
<property name="openjpa.slice.Master" value="ONE"/>
<property name="openjpa.slice.Lenient" value="true"/>
<property name="openjpa.ConnectionDriverName"
value="com.ibm.db2.jcc.DB2Driver" />
<property name="openjpa.ConnectionURL"
value="jdbc:db2://localhost:52000/DB1"/>
<property name="openjpa.ConnectionUserName"
value="db2admin"/>
<property name="openjpa.ConnectionPassword"
value="db2admin,001" />
<property name="openjpa.slice.ONE.ConnectionDriverName"
value="com.ibm.db2.jcc.DB2Driver" />
<property name="openjpa.slice.ONE.ConnectionURL"
value="jdbc:db2://localhost:52000/DB1"/>
<property name="openjpa.slice.ONE.ConnectionUserName"
value="db2admin"/>
<property name="openjpa.slice.ONE.ConnectionPassword"
value="db2admin,001" />
<property name="openjpa.slice.TWO.ConnectionDriverName"
value="com.ibm.db2.jcc.DB2Driver" />
<property name="openjpa.slice.TWO.ConnectionURL"
value="jdbc:db2://localhost:52000/DB2"/>
<property name="openjpa.slice.TWO.ConnectionUserName"
value="db2admin"/>
<property name="openjpa.slice.TWO.ConnectionPassword"
value="db2admin,001" />
<property name="openjpa.slice.DistributionPolicy"
value="org.apache.openjpa.slice.policy.MyUserDistributionPolicy"/>
<property name="openjpa.Log" value="SQL=TRACE"/>
</properties>
</persistence-unit>
I want to use 2 several databases. For testing I build a simple database
structure with one table in each database. Each database is connected to a
slice so, Userdb1 is in slice one and Customerdb2 is in slice two.
When I try to make a simple SELECT udb1.udb1Id, udb1.udb1Name, udb1.udb1Mail
FROM Userdb1 udb1, I have this error : DB2 SQL error: SQLCODE: -204, SQLSTATE:
42704, ...
Slice want to find Userdb1 in slice TWO but this table is in slice ONE only...
How I can do solve this problem ?
Best regards :)
-----
Pinaki Poddar http://ppoddar.blogspot.com/
http://www.linkedin.com/in/pinakipoddar
OpenJPA PMC Member/Committer
JPA Expert Group Member
--
View this message in context:
http://n2.nabble.com/Slice-Error-with-simple-query-%28-Websphere-7.0---DB2-9.1-%29-tp2544575p2546151.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.