[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: Re: Hibernate multiple databases
From:       "Antal van Kalleveen" <antal () vankalleveen ! net>
Date:       2014-10-27 10:54:29
Message-ID: 2.373fb22ce165a26977cc () HOME
[Download RAW message or body]

Hi,

Unfortunately i dont really have any documentation other than the sources on github \
;)

The basic setup is to contribute a 'SessionFactoryConfiguration' to \
'SessionFactorySource' like this : in the 'AppModule'

---------------------------------------------------------------------
    /* 
    * contribute at least one default factory based on hibernate.cfg.xml found on the \
                classpath..
    */
    public void contributeSessionFactorySource(MappedConfiguration<String,SessionFactoryConfiguration> \
configuration) {  
    try {	
    	
		   final SessionFactoryConfiguration defaultConfig = new \
SessionFactoryConfiguration(new String[] \
{"nl.intercommit.weaves.demo.entities.factory1"},new File(  \
this.getClass().getResource("/hibernate.cfg.xml").toURI()));  // get in as first!
		   configuration.add("T5SessionFactory",defaultConfig);
		   
		  final SessionFactoryConfiguration anotherConfig = new \
SessionFactoryConfiguration(new String[] \
{"nl.intercommit.weaves.demo.entities.factory2"},new File(  \
this.getClass().getResource("/someconfig.cfg.xml").toURI()));  // and another one.
		   configuration.add("Otherfactory",anotherConfig);
    } catch (URISyntaxException use) {
    	throw new TapestryException("could not initialize session factories",use);
    }
 	   
    }
---------------------------------------------------------------------

Then in your 'page' code, create a Hibernate Session from the @Injected \
'HibernateMultiSessionManager'


---------------------------------------------------------------------

        @Inject
	private HibernateMultiSessionManager manager;
	
	private Session session1;
	
	private Session session2;
	
	private void onActivate() {
		
		session1 = manager.getSession(SomeEntity.class);
		session2 = manager.getSession("Otherfactory");
        }

---------------------------------------------------------------------

this will create 2 different session to 2 different Databases, assuming the entity \
'SomeEntity' does not belong to the 'Otherfactory'


regards,
  Antal




---- OriginalMessage ----
> From: "Nathan Quirynen" <nathan@pensionarchitects.be>
> To: "Tapestry users" <users@tapestry.apache.org>
> Sent: Tue, Oct 21, 2014, 11:50
> Subject: Re: Hibernate multiple databases
> 
> Hey Antal,
> 
> Thanks for sharing your library! Will surely help me.
> Is there any place I can find how to make use of it (documentation or
> examples)?
> 
> Thanks,
> Nathan
> 
> On 14/10/14 09:26, Antal van Kalleveen wrote:
> > Hi Nathan,
> > 
> > I've written a module which has support for multiple databases through Hibernate. \
> > It's roughly based on Taha's implementation. Besides that it contains a lot more \
> > usefull components ;) 
> > See: https://github.com/intercommit/Weaves
> > 
> > Regards,
> > Antal
> > 
> > 
> > 
> > ---- OriginalMessage ----
> > > From: "Nathan Quirynen" <nathan@pensionarchitects.be>
> > > To: "Tapestry users" <users@tapestry.apache.org>
> > > Sent: Mon, Oct 13, 2014, 14:33
> > > Subject: Hibernate multiple databases
> > > 
> > > Hi,
> > > 
> > > For our current project we have the need to be able to connect to
> > > multiple databases using Hibernate.
> > > I have seen the blog post of Taha
> > > (http://tawus.wordpress.com/2012/03/03/tapestry-hibernate-multiple-databases/)
> > > and was wondering if there exists a library based on this or similar
> > > that I can use as is? Else I will have to investigate in creating one
> > > myself.
> > > 
> > > Greetings Nathan
> > > 
> > > ---------------------------------------------------------------------
> > > 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
> > 
> 
> ---------------------------------------------------------------------
> 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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic