Multiple Database With NHibernate?

Apr 16, 2010

I have two databases. One from Oracle 10g. Another from Mysql. I have configured my web application with Nhibernate for Oracle and now I am in need of using the MySQL database. So how can i configure the hibernate.cfg.xml so that i can use both of the database at the same application?

My current hibernate.cfg.xml is:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>[code]......

View 1 Replies


Similar Messages:

C# - NHibernate: Getting Multiple Entities With Subset Of Child Collection?

Jan 16, 2010

My classes look something like this (I include only the relevant properties):

public class Order
{
public virtual Customer Customer { get; set; }
public virtual IEnumerable<OrderLine> OrderLines { get; set; }
}
public class OrderLine
{
public virtual string Product { get; set; } // Simplified
}

Now I What I want is to create a detached criteria that selects all orders for a given customer, and at the same time retrieves only the first 10 OrderLines for each order. The first part is easy:

Customer someCustomerObject = ...; var criteria = DetachedCriteria.For<Order> ).Add(Restrictions.Eq("Customer", someCustomerObject);

But how do I instruct NHibernate to retrieve eagerly the first 10 orderlines for each order retrieved by the criteria above?

I've tried using a Filter based on the following example (taken from Nhibernate documentation):

session.CreateFilter( lazyCollection, "").SetFirstResult(0).SetMaxResults(10).List();

But when I give Order.OrderLines to the CreateFilter method, it retrieves all orderlines first, and then afterwards retrieves the 10 first orderlines, which is not what I want. I also tried combining this with a call to NHibernateUtil.Initialize to no avail.

How do I create a detached criteria for this problem? Or, if that is not entirely possible, how to I retrieve, for each order, the 10 first results only, without fetching the entire collection?

View 1 Replies

NHibernate - Two SessionFactories Accessing The Same Database?

Jan 4, 2011

This is related to a previous question I asked, regarding splitting a asp.net mvc web application into two apps - one public, and one admin. Both of them would be sharing the same database of course.

With two web apps I'll have two host applications and so two seperate Nihbernate session factories. My concern is that their seperate data caches will cause all sorts of problems.

While posting this, I looked at this question, which covers a similar problem (for a different reason). I really don't want to have to set up some kind of distributed cache just for a low use admin application.

How can this be resolved? Is separating the admin section into it's own application not possible with NHibernate without drastic measures?

View 2 Replies

NHibernate Inner Join An Oracle And Sql Server Database?

Aug 2, 2010

I am building an object from multiple datasources. Does anyone know whether this is possible in NHibernate and how. I should mention that one source is SQL the other ORACLE.

View 1 Replies

Updating Schema Of Production Database With NHibernate And Adding Default Data?

Sep 24, 2010

here's the situation:

You're using NHibernate with Fluent NHibernate for mappings.

You have an application in production with a database with live data You're adding a new feature in development and it requires a new database column.

The new column cannot be blank. For example, I recently had to a DateCreated column to a table and the app now uses that date. As the only time the data will be missing is now, it seems unnecessary to add code to check for errors.

In my application I have an updater which can execute a SchemaUpdate to add the new database column - however, the application will starting crashing as it is expecting a value in the new column.

I need to get some sensible default data into that column. In this case I manually ran an Update to set the date to the current date (good enough for the situation). In this particular case I believe that you cannot set the column default to getdate() using fluent mappings.

Keep a schema version number in a config file In the updater that runs SchemaUpdate start adding upgrade methods for each version. These methods would run updates to add default data (or other required actions).

After the schema update has been run, call all methods required for a version greater than the current version (i.e. those that haven't previously been run). So if the app is now version 4 and version 2 is installed, methods 3 and 4 would be run.

View 3 Replies

Can Write A Unit Test For CRUD Using In Memory Database With Fluent Nhibernate

Jul 6, 2010

How can I write a unit test for CRUD using in memory database with fluent nhibernate

View 2 Replies

Delete Multiple Row From The Database At Once

Jan 2, 2011

i working on visual studio 2008 with my database in sql server 2005 i have created a chat online apps once the user is online he/she will chat and chat data will go in my message database which has this column

MessageID(pk)
RoomID
UserID
ToUserID
Text

after the chatter finish's chat he log's out and the messages send by the "UserID" or say chat data in message table of that USerID must be deleted so i want to delete muliple row from the database at once.

View 2 Replies

How To Use NHibernate With 3.5

Aug 27, 2010

I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on Google but couldn't find the complete explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.

View 4 Replies

MVC :: How To Download Multiple Files From Database

Dec 16, 2010

am able to download single files which is coming as bytes from database..how to go with multiple files....

View 4 Replies

How To Save Multiple Column In Database

May 19, 2010

I have a text file.I need to get data from this text file and show on grid ,1)After this user can update information from gridview, 2)Click on save button save data on database.Before clicking on button data don't save on database.How to do that?

View 1 Replies

Security :: Multiple Database On Same Portal?

Oct 20, 2010

I am working on a project where on the same portal people from different location will login, so they get connected to different database depending on the location they choose at the time of login. There will be a dropdown list during login, where user can choose the locationI use ASP.NET Login control, security/membership class.So what is the best way to implement this, should i save different connection string in web.config and based on location choosen by user read them? I would also have to change LocalSqlServer connection string for login control, how do i do this dynamicaly?

View 3 Replies

ADO.NET :: Multiple Upload And Save To Database?

Dec 1, 2010

[Code]....

Multiple upload and save to database..

View 4 Replies

Security :: Membership Against Multiple Database?

Feb 19, 2010

I am facing a very unique situation and need help. My problem is as follows:1. I have a basic ASP.NET website (3.5 is it helps on IIS 7) where I have implemented Membership for Authentication.2. The site caters to multiple companies (Say Company A, Company B etc.).3. For each company I need to have different database (SQL 2008). This is mandatory as i can use multiple Application in there.Now as far as the flow is concern its pretty simple:1. The user comes to this site with a QueryString like cid=123 (in actual there is a HttpModule for this, cid=123 is just for this forum purpose).2. The site using the cid=123 gets to know this user is for Company A (i have a WCF service for this, how it works is not a problem.), along with that I also get the connectionstring for the database this user should use.3. For Business implementation i have handled this nicely in my DAL Layer.4. The problem comes with Membership.5. In Membership I have writtent a custom provider, that assigns the connection on teh fly.6. But this happens only once for the application. i.e. the connectio string gets cached at application level.7. The connection string does not change untill I reset my IISwhere i can have a single WebSite, catering to different companies, using seperated databases and using Membership for Authorization.

public class CustomMembershipProvider : SqlMembershipProvider
{
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)

[code]...

View 1 Replies

Can't Get Nhibernate To Work

Aug 12, 2010

I am about to give up on this pos...unless somebody here simply gives me the right code to fix my problem. I'm tired of running in circles, and scouring the internet with no progress at all.

Problem: not updating collections with FK's.

Example:

Forum forum = new Forum("Sample");
category.AddForum(forum);
categoryRepository.Update(category); <- fails with transient object error for forum with no CategoryId.
Mapped right using References<Category> and HasMany<Forum>. Conventions are as follows.

Ref:

instance.Column(instance.Property.Name + "Id");

HasMany:

instance.Key.Column(instance.EntityType.Name + "Id");
instance.Cascade.All();
instance.Access.ReadOnlyPropertyThroughCamelCaseField(CamelCasePrefix.None);

Now, I've tried every possible setting for inverse, all the different cascades, on both sides. Nothing works. It just flat fails, telling me it can't insert NULL for Forum.CategoryId (field, not entity prop).

View 8 Replies

DDD Approach Be Used With NHibernate?

Nov 12, 2010

I've been reading up on DDD a little bit, and I am confused how this would fit in when using an ORM like NHibernate. Right now I have a .NET MVC application with fairly "fat" controllers, and I'm trying to figure out how best to fix that. Moving this business logic into the model layer would be the best way to do this, but I am unsure how one would do that.

My application is set up so that NHibernate's session is managed by an HttpModule (gets session / transaction out of my way), which is used by repositories that return the entity objects (Think S#arp arch... turns out a really duplicated a lot of their functionality in this). These repositories are used by DataServices, which right now are just wrappers around the Repositories (one-to-one mapping between them, e.g. UserDataService takes a UserRepository, or actually a Repository). These DataServices right now only ensure that data annotations decorating the entity classes are checked when saving / updating.

In this way, my entities are really just data objects, but do not contain any real logic. While I could put some things in the entity classes (e.g. an "Approve" method), when that action needs to do something like sending an e-mail, or touching other non-related objects, or, for instance, checking to see if there are any users that have the same e-mail before approving, etc., then the entity would need access to other repositories, etc. Injecting these with an IoC wouldn't work with NHibernate, so you'd have to use a factory pattern I'm assuming to get these. I don't see how you would mock those in tests though......................

View 3 Replies

ADO.NET :: How To Use Convert() In NHibernate

Aug 10, 2010

I am using NHibernate in my web application. I need to use Convert() method in NHibernate query in order to get the date format as "MM/DD/YYYY".

I have used the below query using NHibernate query SELECT DISTINCT Convert(varchar(10),CurrentDate,101) AS Date FROM table order by Date desc.

But getting error.

Even I tried using views without unique key but Entity requires primary key.

View 2 Replies

C# - NHibernate TDD With Oracle?

Feb 1, 2010

I am working on NHibernate with oracle in ASP.Net. Now i am trying TDD(Test Driven Development). Can you tell me the best way to develop the TDD for NHibernate with oracle?I am using MbUnit with microdesk but it is not better approach for oracle but SQL server.

View 1 Replies

LazyInitializationException In .NET App With NHibernate?

Nov 28, 2010

Using NHibernate with ASP.NET 4.

I have had no issues retrieving objects, but I've just got to a point with nested objects that I can't figure out.

I am using lazy=true and when accessing a lazy-load collection I get the message:

Initializing[type#3]-failed to lazily initialize a collection of role: [type], no session or session was closed

Even if I call SessionFactory.OpenSession() immediately prior to the object being accessed, it makes no difference. I have also tried accessing the collection in a using ISession block to no luck.

Edit to add - I do have current_session_context_class = web set in web.config, and I am using CurrentSessionContext.Bind on BeginRequest.

Not an MVC app

I read this - don't know how accurate it is, and it is Hibernate:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-2878

It says something about a bug in many-to-many relationships.

Here is my HBM mapping:

<bag name="Objects" table="ObjectInstance" cascade="all" lazy="true">
<key column="branchId" />
<many-to-many class="InventoryObjectInstance" column="objectInstanceId" />
</bag>

View 3 Replies

Can Use NHibernate On GoDaddy

Jan 28, 2011

A comment from .Net Hosting (Flexible Medium Trust) says.

Godaddy is medium trust, which means that u can't use stuff like IL emit(Nhibernate needs this for proxying)

Is it true? Is there anyone using NHibernate on GoDaddy?

View 2 Replies

ADO.NET :: NHibernate And WCF Service?

Jul 8, 2010

I am a newcomer to NHibernate and know a bit about WCF. I would like to know how they best play together.Should I make the session per request? Or is there some different tactic that I should be using? What about the lifetime?Where do I set up my sessionfactory? In the global.asax?Can I best create a custom httpmodule or a new servicehostfactory to plug all the goods in?

View 2 Replies

Nhibernate Uses A Lot Of Memory?

Feb 9, 2011

I've got fluent nhibernate in my application and I'm trying to locate the cause of high memory usage. (I say high, it's 60MB, but it's a web app and it's not very big) Unfortunately it looks like a lot of it is in unmanaged memory, so I started taking things out - and as soon as I took out any calls to nhibernate, the memory usage dropped to 11MB!! Why oh why would it be taking up so much memory? Especially, why would it be taking up unmanaged memory?

I've been 'Googling' this all day and all I can find are posts from people saying "NHibernate eats memory..." and answers that say "no it doesn't, there's no evidence". Are NHibernate people in denial about it?

View 1 Replies

Web Forms :: Web Page That Allows Multiple Database Row Updates

Feb 21, 2011

We currently have a page with a listview control that has textboxes and an update button for each row. Users are able to update the database one row at a time.This is problematic in countries where the internet connections are very slow because a round trip is needed for each row update and this can become impossible to use.We need to create a page which allows multiple row updates so that each round trip is more productive. There woudl be just one update button on each page and users could enter values into each row. Clicking the update button would update each changed row
of the database.We currently use linq 2 sql. I would imagine that we could still use this in the above scenario??? Or is there a better data connection methode to use in this scenario.

View 3 Replies

Web Forms :: How To Send Multiple Emails From The Database Using C#

Jan 27, 2010

I have emails stored in my database. The email is shown by a grid view that contains also a checkbox. I would like to send email to all emails that are selected in checkbox in my gridview. The value that the checkbox hold is True and False.

View 20 Replies

ADO.NET :: Entity Framework With Multiple Database Servers

Feb 7, 2011

We have an IVR product that reads a configuration database for callflow information. I am writing a tool for our implementation team that will allow them to add/delete/update the data in the configuration database. Once the tool is in production, the implementer will use only the production release of the tool to modify the configuration database in all four of the IVR regions (Dev, QA, Cert, and Prod). Each region has its own database with identical schemas. The tool has 'tabs' across the top for each region. If a user is currently working in the Dev region and clicks the QA tab, how do I switch my connection from the Dev db server to the QA db server?

View 3 Replies

C# - Display Multiple Images From Database To Page

Mar 29, 2011

i am creating a page that will display multiple images from the database. i can do it if i will only display one image, by using a page to be rendered as image. something like this...

using (SqlDataReader reader = comm.ExecuteReader())
{
Byte[] images = new Byte[]();
while (reader.Read())
{
Response.BinaryWrite(images);
}
}

and in the aspx file i have: <asp:Image ID="imgPhoto" runat="server" ImageUrl="~/ShowImages/LoadImages.aspx" Height="100px" Width="100px" BorderWidth="1px" /> what i want to achieve is to display multiple images from the database without making a page to be rendered as image...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved