If you're not planning on using Hibernate for fetching data from the second datasource, then you dont need to define a second SessionFactory bean. Just define a second DataSource bean and inject it into your DAO's. You can then use the Spring JDBC helper classes by utilizing the DB2 DataSource that you injected in your DAO's. All of the Spring JDBC helper classes like MappingSqlQuery and JdbcTemplate can be constructed using a DataSource object.
On 4/20/07, Nathan Anderson <[EMAIL PROTECTED]> wrote:
Hi Sanjiv, I wasn't sure what I would use to fetch the data from the DB2 database. Hibernate crossed my mind, but then it seemed like it would not be worth the difficulty of just getting the object to map correctly. I haven't used iBATIS before, so I was starting to look at what JDBC templates Spring has [http://www.springframework.org/docs/reference/jdbc.html ]. This is a very simple app other than the fact that there are 2 data sources. Given the limited time to spend on it and the fact it won't be used a lot [maybe 10 users max], I'm going for simple ;) Thanks for the tip and the warning, Nathan Sanjiv Jivan wrote: > You just need to define a second SessionFactory bean and inject it in > the DAO's that you need access to it. You'll have to manage this > second session opening and closing manually since the > OpenSessionInViewFilter manages just the the bean names > "sessionFactory". You could setup a second OSIV filter but it might be > overkill depending on how frequently you need to fetch data from your > DB2 database. > > I would personally use Ibatis for fetching read-only data since it > takes a lot of work to get Hibernate to perform efficiently as a data > mapper alone when you dont need its ORM capabilities. (Getting > Hibernate to perform efficiently when working with large amounts of > read only data is a battle I've almost given up on). However if would > still like to use Hibernate for your read-only DB2 data, make sure > you're using Hibernate's StatelessSession API or else you'll just be > paying a huge CPU and memory overhead using Hiberanate. > > On 4/20/07, *Nathan Anderson* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > [ You thought I was kidding about the 60 seconds, huh? ;) ] > > So I need to have 2 data sources in my application. The AppFuse core > and my CRUD classes are being persisted to a MySQL database. I also > need fetch Read-Only objects from a DB2 database. Being new to maven > I'm a little stumped on how to add the JDBC jars for DB2. But even > after I figure that out I'm not sure how to configure a second > dataSource. I'm guessing I create a new "dataSource" bean, but I > don't > see how to tell Hibernate or some other mechanism to connect to it. > > Thanks, > Nathan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
