You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by esper <ma...@yahoo.com> on 2012/09/25 13:36:06 UTC
Again with the tapestry, hibernate and switching the database
Hi,
here's the problem that I'm facing.
I have a project with several databases (separate databases but the schemas
are the same!).
I want to decide which database to use when the user authenticates. That
user could use *only one database at the time* but he could switch between
them if he wants.
How to tell tapestry and hibernate that? It's not the authentication
explanation I want - different hibernate configuration is what I'm
interested in.
Can someone assist me with this?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Again with the tapestry, hibernate and switching the database
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 27 Sep 2012 09:48:41 -0300, esper <ma...@yahoo.com> wrote:
> You don't have to be sorry, I understand.
> Can you please point me in the right direction on where to start reading
> about this stuff?
You're already in the right path.
> How do I disable hibernate-tapestry module?
Just don't add it to your classpath.
> How do I set up hibernate and
> tapestry to run independently from one another?
Just use Hibernate just like you weren't using Tapestry. They're
completely separate and independent from each other.
--
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Again with the tapestry, hibernate and switching the database
Posted by esper <ma...@yahoo.com>.
You don't have to be sorry, I understand.
Can you please point me in the right direction on where to start reading
about this stuff?
How do I disable hibernate-tapestry module? How do I set up hibernate and
tapestry to run independently from one another?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477p5716523.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Again with the tapestry, hibernate and switching the database
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 26 Sep 2012 03:57:09 -0300, esper <ma...@yahoo.com> wrote:
> Thanks for the reply Taha! It is indeed very useful.
> I still find it hard to believe that you can't load/rebuild the entire
> different hibernate session with Tapestry. No matter the time it takes.
I'm sorry, but you're completely wrong here. As Taha said,
tapestry-hibernate doesn't support multiple databases. But you can use
Tapestry and Hibernate together without using tapestry-hibernate. Tapestry
itself doesn't mandate how you should use Hibernate (or any other
framework.
> said, I only need those databases to work one at the time.
>
> Somehow I imagined it like this:
> - create different hibernate configuration for each database
> - create a session helper to execute something like this
> sessionFactory = new Configuration().configure().buildSessionFactory();
> - load the session object back to tapestry
>
> But, can it be done?
Yes.
--
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Again with the tapestry, hibernate and switching the database
Posted by Taha Siddiqi <ta...@gmail.com>.
My point here is that you can't do it with tapestry-hibernate module but you can always do it with "tapestry" and "hibernate". :)
You can take a look at https://github.com/tawus/tapestry5 where I have modified tapestry-hibernate to work with multiple databases. If you can tweak it further you might to able to accomplish choosing session based on client.
On Sep 26, 2012, at 12:27 PM, esper wrote:
> Thanks for the reply Taha! It is indeed very useful.
> I still find it hard to believe that you can't load/rebuild the entire
> different hibernate session with Tapestry. No matter the time it takes. As I
> said, I only need those databases to work one at the time.
>
> Somehow I imagined it like this:
> - create different hibernate configuration for each database
> - create a session helper to execute something like this
> sessionFactory = new Configuration().configure().buildSessionFactory();
> - load the session object back to tapestry
>
> But, can it be done?
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477p5716495.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Re: Again with the tapestry, hibernate and switching the database
Posted by esper <ma...@yahoo.com>.
Thanks for the reply Taha! It is indeed very useful.
I still find it hard to believe that you can't load/rebuild the entire
different hibernate session with Tapestry. No matter the time it takes. As I
said, I only need those databases to work one at the time.
Somehow I imagined it like this:
- create different hibernate configuration for each database
- create a session helper to execute something like this
sessionFactory = new Configuration().configure().buildSessionFactory();
- load the session object back to tapestry
But, can it be done?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477p5716495.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Again with the tapestry, hibernate and switching the database
Posted by Taha Siddiqi <ta...@gmail.com>.
If your databases are having same schema then multi-tenancy is an option.
http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch16.html
If there are completely different databases then I don't think you can do that with tapestry-hibernate database. Tapestry-hibernate does not support multiple databases. Tapestry-jpa does support multiple-databases.
With tapestry-jpa you can setup multiple databases and for switching based on client, you will have to use EntityManagerManager
http://tapestry.apache.org/5.3.4/apidocs/org/apache/tapestry5/jpa/EntityManagerManager.html
and choose the database(persistence context) based on the client.
On Sep 25, 2012, at 5:18 PM, esper wrote:
> Can you please elaborate? I don't think I understand...
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477p5716482.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Re: Again with the tapestry, hibernate and switching the database
Posted by esper <ma...@yahoo.com>.
Can you please elaborate? I don't think I understand...
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477p5716482.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Again with the tapestry, hibernate and switching the database
Posted by Taha Siddiqi <ta...@gmail.com>.
Hi
If it is a new application, you can try new multi-tenancy in hibernate or JPA.
On Sep 25, 2012, at 5:06 PM, esper wrote:
> Hi,
>
> here's the problem that I'm facing.
> I have a project with several databases (separate databases but the schemas
> are the same!).
> I want to decide which database to use when the user authenticates. That
> user could use *only one database at the time* but he could switch between
> them if he wants.
>
> How to tell tapestry and hibernate that? It's not the authentication
> explanation I want - different hibernate configuration is what I'm
> interested in.
>
> Can someone assist me with this?
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Again-with-the-tapestry-hibernate-and-switching-the-database-tp5716477.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org