You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Fabio Martelli <fa...@gmail.com> on 2012/11/10 17:11:17 UTC
working with slices
Hi All,
I'm working on some extensions around openjpa-slice but I have some difficulties to understand/configure slice about delete operations.
I ask for the following operation
entityManager.createQuery("DELETE FROM MPObject p").executeUpdate();
Since my MPObject exists on one and only one slice I obtain the following error message
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Invalid object name 'MPObject'. {prepstmnt 175442873 DELETE FROM MPObject} [code=208, state=S0002]
Have I missed something? Please, let me know how can I solve my problem.
Thank you in advance.
Best regards,
F.
Re: working with slices
Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 26/nov/2012, alle ore 14.46, Pinaki Poddar ha scritto:
> Hello Fabio,
> Look for the following findTargets() method in DistributedStoreQuery.java
>> List<SliceStoreManager> targets = findTargets();
>
> The query uses this method to narrow the slices to a subset.
>
> The same technique on delete() and update() should work. If the
> delete()/update() not calling them, they should.
>
> From a usage point of view, the same mechanics of
>
> String hint = "openjpa.hint.slice.Target";
> Query query = em.createQuery("SELECT p FROM PObject")
> .setHint(hint, new String[]{"One",
> "Two"});
>
>
> On a broader note:
>> I'm going to add Microsoft Windows Azure SQL Database support into
> OpenJPA.
>> Since for my purpose I decided to start from slice I have to customize
> some slice behavior.
>
> Liked the idea of using OpenJPA/Slice in Azure cloud environment. Though
> Slice was developed in a pre-cloud era -- its primary motivation was to
> address data distribution. But I believe Slice can be easily used in a
> multi-tenancy scenarios in a cloud environment. As you work through Slice
> and Azure, please keep posting your findings (and patches).
> Good luck with your project :)
>
Hi Pinaki,
you can have more info about the project at https://github.com/Tirasa/OpenJPA-Azure.
Best regards,
F.
>
>
>
>
> -----
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/working-with-slices-tp7581693p7581928.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: working with slices
Posted by Pinaki Poddar <pp...@apache.org>.
Hello Fabio,
Look for the following findTargets() method in DistributedStoreQuery.java
> List<SliceStoreManager> targets = findTargets();
The query uses this method to narrow the slices to a subset.
The same technique on delete() and update() should work. If the
delete()/update() not calling them, they should.
From a usage point of view, the same mechanics of
String hint = "openjpa.hint.slice.Target";
Query query = em.createQuery("SELECT p FROM PObject")
.setHint(hint, new String[]{"One",
"Two"});
On a broader note:
> I'm going to add Microsoft Windows Azure SQL Database support into
OpenJPA.
> Since for my purpose I decided to start from slice I have to customize
some slice behavior.
Liked the idea of using OpenJPA/Slice in Azure cloud environment. Though
Slice was developed in a pre-cloud era -- its primary motivation was to
address data distribution. But I believe Slice can be easily used in a
multi-tenancy scenarios in a cloud environment. As you work through Slice
and Azure, please keep posting your findings (and patches).
Good luck with your project :)
-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/working-with-slices-tp7581693p7581928.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: working with slices
Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 21/nov/2012, alle ore 18.39, Pinaki Poddar ha scritto:
> Hello Fabio,
> Slice, by default, expects that each slice has identical schema. In your
> case seems to deviate from that assumption.
>
> One suggestion would be to set a hint "openjpa.hint.slice.Target" [1] to
> confine the delete operation to e executed in the slice of your choice.
Hi Pinaki,
thank you for your reply.
Unfortunately I need to work with different schemas on different slices.
I'm going to add Microsoft Windows Azure SQL Database support into OpenJPA.
Since for my purpose I decided to start from slice I have to customize some slice behavior.
Of course, my changes should be applied just in case of Azure configuration.
I mean, at the end I'd like to be able to perform a slice configuration including slices for azure federations and others DBMSs.
Any comment/suggestion/remark will be appreciated.
Best regards,
F.
> [1]
> http://openjpa.apache.org/builds/2.2.0/apache-openjpa/docs/manual.html#d5e16664
>
>
>
> -----
> Pinaki Poddar
> Chair, Apache OpenJPA Project
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/working-with-slices-tp7581693p7581892.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: working with slices
Posted by Pinaki Poddar <pp...@apache.org>.
Hello Fabio,
Slice, by default, expects that each slice has identical schema. In your
case seems to deviate from that assumption.
One suggestion would be to set a hint "openjpa.hint.slice.Target" [1] to
confine the delete operation to e executed in the slice of your choice.
[1]
http://openjpa.apache.org/builds/2.2.0/apache-openjpa/docs/manual.html#d5e16664
-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/working-with-slices-tp7581693p7581892.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: working with slices
Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 10/nov/2012, alle ore 17.11, Fabio Martelli ha scritto:
> Hi All,
> I'm working on some extensions around openjpa-slice but I have some difficulties to understand/configure slice about delete operations.
>
> I ask for the following operation
> entityManager.createQuery("DELETE FROM MPObject p").executeUpdate();
>
> Since my MPObject exists on one and only one slice I obtain the following error message
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Invalid object name 'MPObject'. {prepstmnt 175442873 DELETE FROM MPObject} [code=208, state=S0002]
>
> Have I missed something? Please, let me know how can I solve my problem.
Hi All,
since I didn't receive any suggestion I have approached the problem by overriding some behaviors.
In fact, I performed the following two changes:
1. modified executeDelete and executeUpdate methods of DistributedSQLStoreQuery and DistributedStoreQuery classes in order to search for targets like done into the executeQuery method (same locations/classes).
2. overridden deleteAll and updateAll methods in order to use the provided QueryTargetPolicy implementation to retrieve and set "targets".
Am I wrong? Any suggestions/comments/remarks are welcome.
If you think than my changes can be correct, I can open a new issue and attach the patch.
Please, let me know.
Best regards,
F.