sessionfactory

Multiple Session Factories under Spring/Hibernate

I have been given a requirement where I need to support multiple databases in the same instance, to support multi-tenancy. Each DB has an identical schema. The user logs into a specific database by choosing from a list, and all subsequent calls will go to that DB until they log out. I want to hot swap the session factory inside a single...

Hibernate: Is it okay to not bind SessionFactory to a JNDI name?

There is a way to set the JNDI name of a SessionFactory in the hibernate.cfg.xml file. However, if I'm not explicitly using JNDI lookup to get my SessionFactory at all in my web app, is it okay to NOT give it a JNDI name? The reason I ask is that if I didn't set up my JNDI name, my JUnit tests will run fine. But if I do set it up by onl...

FluentNHibernate Session Management in ASP.NET

New to NHibernate(my disclaimer). I came across a similar and interesting article regarding MVC, however, I'm more curious as to what general best practices are for managing NHibernate sessions within a generic web application. I've come across the Burrow project, but I'm starting to realize there seems to be a few different directions ...

Problems using eclipse Hibernate plugin - could not locate sessionfactory in JNDI

Hi Guys, I'm using the reverse engineering capabilities built into the eclipse hibernate plugin to generate dao's and hbm.xml files for each table. It does it quite well but when I try to use the generated Objects I get a Could not locate SessionFactory in JNDI error. I saw a post that suggested this happens when you name your Session...

nhibernate session for different database servers with same entity

We use two databases in our web-application. One is located in USA and one is in Canada. You should see only the data based on your country. Now I think there will be a problem when it comes to create the SessionFactory objects, because the entities were already created for USA. Now when nHibernate tries to create the factory for the CAN...

Connect NHibernate to different databases with same schema

We are in the process of splitting our db into several smaller ones. The schemas will be exactly the same and we will control which db the system connects to when the client logs in. I receive an error if I do not set a connection string in my nhibernate configuration. I do not want to create a factory for each db. Is it possible to hav...

org.hibernate.HibernateException: No session currently bound to execution context

I'm trying to integrate Spring Security with Hibernate. I'm new to both technologies so I'm almost certainly taking too many steps at once here, but I'm at the point where I want to authenticate a user from the database. I think this is certainly more a Hibernate problem that a Spring Security one but I mention it to give some context. ...

In Grails how do I access the hibernate session inside of a domain class static method?

I've read various articles on the web, but they seem rather scattered on this point. Exactly what do I need to do in my configuration and in my method to get the hibernate session. I'm trying to make some direct sql calls for stored procedures. I have a large code base that I am porting from Ruby with lots of static methods and stored...

transactionmanager using same datasource

(connected to db call abc)--->datasource1 ---> LocalSessionFactoryBean --->transactionManager1 (connected to db call abc)--->datasource1----->AnnotationSessionFactoryBean -->transactionManager2 the reason i have 2 sessionfactory is because one is used by 3rd party osworkflow library and latter use by my application since both are co...

multiple session factories, one connection?

Hi all, To avoid XA overhead I prefixed some table names from project A and rolled it out to be inside the same mysql database as project B so I can use the same connection - and hope to get full atomicity etc. Project A and B though have very different session factory configs. I have a HibernateTransactionManager configured for projec...

Ensure NHibernate SessionFactory is only created once

I have written an NHibernateSessionFactory class which holds a static Nhibernate ISessionFactory. This is used to make sure we only have one session factory, and the first time OpenSession() is called I create the actuall SessionFactory - next times I use the same and open a session on it. The code looks like this: public class Nhibern...

Hibernate SessionFactory: how to configure JNDI in Tomcat?

that's how the session factory should be gotten: protected SessionFactory getSessionFactory() { try { return (SessionFactory) new InitialContext() .lookup("SessionFactory"); } catch (Exception e) { } } Please provide a simple solution for Tomcat6 to be able to get Sessi...

SessionFactory in Hibernate

Hi, I am using hibernate-2.1 and "net.sf.hibernate.SessionFactory" class in my spring project. Now I am switched to Spring 2.5.6.A, where they are using hibernate3 and I am not able to find out the "net.sf.hibernate" package in that. But I found SessionFactory class in the package "org.springframework.orm.toplink". Is both the class ...

Instantiation failure and singleton-behaviour interaction [NInject1]

I have set up a NInject (using version 1.5) binding like this: Bind<ISessionFactory>().ToMethod<ISessionFactory>(ctx => { try { // create session factory, might fail because of database issues like wrong connection string } catch (Exception e) { throw new DatabaseException(e); } }).Using<Singleto...

Runtime one-way mapping of n tables to 1 class in Hibernate

Hi, I have data in different tables but in the same database, all of which have the same schema. Depending on some runtime variable, I want to choose which table to use when querying Hibernate. Is this possible? Note that I only use Hibernate to read table-data to objects. A solution (I think) would be one *.hbm.xml-file per table an...

What is a good way to setup CRUD methods and SessionFactory in Nhibernate?

I currently have a NHibernateHelper class which creates a session factory. I keep recieving errors saying 'Session Closed!'. Am I going about this in the wrong way? The error occurs when I call the Add(Login login) which gets called after Add(User user) public class NHibernateHelper { private static ISessionFactory _sessionFactory; ...

how can i automatically generate a non id value in hibernate?

I am using hibernate annotations, spring, a sessionFactory and defining everything in a context.xml (like so..) <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="myDataSource" /> <property name="annotatedClasses"> <...

SessionFactory - one factory for multiple databases.

Hi, We have a situation where we have multiple databases with identical schema, but different data in each. We're creating a single session factory to handle this. The problem is that we don't know which database we'll connect to until runtime, when we can provide that. But on startup to get the factory build, we need to connect to a...

ISession per Request (Only when necessary)

Hi Friends, I'm developing an application (asp.net mvc) and I'm using ISession per request (in globa.asax I use Bind and Unbind in Begin_Request event and End_Request event). Everything works fine but sometimes (some requests) I don't need to use an ISession (a connection with database). I'd like to know if is there any way to open an ...

Castle Windsor: master controller not resolving the registered components in the container

Having the code below in my Global.asax.cs and two controller (one based on a the other: MasterController) I don't seem to find how can I resolve the repository register in my WindsorContainer from the MasterController... the same applies in the HomeController and works perfectly... what am I doing wrong? Global.asax.cs: private IWinds...