These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Multi-database mapping on same server / Invalid object name
PostPosted: Thu Jun 14, 2007 7:02 pm 
Newbie

Joined: Thu Jun 14, 2007 6:41 pm
Posts: 1
Hi,

Recently I ran into a problem of splitting my database into 2 databases which still occupy on the same server (SQL Server 2005).

I've found some info about "schema" attribute for hibernate-config tag in hbm.xml file. Here http://forum.hibernate.org/viewtopic.php?t=962161 I've found a short info on that solution.

Unfortunately, I can't make it work in my solution. Here's my entities configured for their schemas:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" schema="RMSUat.dbo" assembly="Catalyst.CatalystRMS.ClientApp.Entities" namespace="Catalyst.CatalystRMS.ClientApp.Entities">
<class name="Catalyst.CatalystRMS.ClientApp.Entities.Patient, Catalyst.CatalystRMS.ClientApp.Entities" table="Patient" dynamic-update="true">

   <id name="PatientId" column="PatientId" type="Guid">
      <generator class="identity"/>
      </id>

. . .


and

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" schema="RMSMaster.dbo" assembly="Catalyst.CatalystRMS.ClientApp.Entities" namespace="Catalyst.CatalystRMS.ClientApp.Entities">
<class name="Catalyst.CatalystRMS.ClientApp.Entities.PatientStatus, Catalyst.CatalystRMS.ClientApp.Entities" table="PatientStatus" >
  <id name="PatientStatusCd" column="PatientStatusCd" type="string">
    <generator class="identity"/>
  </id>
<property name="Description" column="Description" type="String" length="50" />

. . .



Whenever I try to use any of those wntities, I get and exception:


Code:
[SqlException (0x80131904): Invalid object name 'RMSUat.dbo.Patient'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
   System.Data.SqlClient.SqlDataReader.get_MetaData() +62
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +122
   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +9
   NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd) +32
   NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session) +182
   NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +175
   NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +56
   NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Type optionalEntityName, Object optionalIdentifier, IEntityPersister persister) +252

[ADOException: could not load an entity: [Catalyst.CatalystRMS.ClientApp.Entities.Patient#8edecab6-bf19-dc11-b373-000c2911986a][SQL: SELECT patient0_.PatientId as PatientId6_0_, patient0_.FirstName as FirstName6_0_, patient0_.LastName as LastName6_0_, patient0_.UsualName as UsualName6_0_, patient0_.RoomNumber as RoomNumber6_0_, patient0_.Pin as Pin6_0_, patient0_.PolicyNumber as PolicyNu7_6_0_, patient0_.Dob as Dob6_0_, patient0_.GenderCd as GenderCd6_0_, patient0_.MaritalStatusCd as Marital10_6_0_, patient0_.PatientStatusCd as Patient11_6_0_, patient0_.ImageURL as ImageURL6_0_, patient0_.TitleId as TitleId6_0_, patient0_.PatientPhone as Patient14_6_0_, patient0_.CitizenshipId as Citizen15_6_0_, patient0_.CountryOfBirthId as Country16_6_0_, patient0_.Weight as Weight6_0_, patient0_.PatientStatusReasonId as Patient18_6_0_, patient0_.StatusComments as StatusC19_6_0_, patient0_.InsurancePlanId as Insuran20_6_0_, patient0_.ReligiousCulturalNeeds as Religio21_6_0_, patient0_.BloodTypeId as BloodTy22_6_0_, patient0_.AdvanceDirective as Advance23_6_0_, patient0_.ADPatientContactId as ADPatie24_6_0_, patient0_.AdvanceDirectiveRequest as Advance25_6_0_, patient0_.IsCardioRes as IsCardi26_6_0_, patient0_.IsAdmissionToIntensiveCare as IsAdmis27_6_0_, patient0_.IsIntravenousTherapy as IsIntra28_6_0_, patient0_.IsTubeFeeding as IsTubeF29_6_0_, patient0_.IsOther as IsOther6_0_, patient0_.OtherSpecify as OtherSp31_6_0_, patient0_.DispensingComments as Dispens32_6_0_, patient0_.FileNumber as FileNumber6_0_, patient0_.SocialInsurance as SocialI34_6_0_, patient0_.InsurancePlan2Id as Insuran35_6_0_, patient0_.PolicyNumber2 as PolicyN36_6_0_, patient0_.ReceivingGIS as Receivi37_6_0_, patient0_.IsActive as IsActive6_0_, patient0_.AddUserName as AddUser39_6_0_, patient0_.AddDatetime as AddDate40_6_0_, patient0_.UpdUserName as UpdUser41_6_0_, patient0_.UpdDatetime as UpdDate42_6_0_, patient0_.MoveInDate as MoveInDate6_0_, patient0_.ResidentType as Residen44_6_0_, patient0_.CareLevelCd as CareLev45_6_0_, patient0_.ReligionId as ReligionId6_0_ FROM RMSUat.dbo.Patient patient0_ WHERE patient0_.PatientId=?]]
   NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Type optionalEntityName, Object optionalIdentifier, IEntityPersister persister) +370
   NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId) +32
   NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session) +17
   NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session) +117
   NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted) +958
   NHibernate.Impl.SessionImpl.ImmediateLoad(Type clazz, Object id) +19
   NHibernate.Proxy.LazyInitializer.Initialize() +69
   NHibernate.Proxy.CastleLazyInitializer.Intercept(IInvocation invocation, Object[] args) +89
   CProxyTypeCatalyst_CatalystRMS_ClientApp_EntitiesPatientEntities_NHibernate_ProxyINHibernateProxy1.get_FirstName() +99
   Dapasoft.Paragon.Paragon.WebForm1.Button1_Click(Object sender, EventArgs e) in C:\PROJECTS\ParagonNurse\WEB\test\WebForm1.aspx.vb:15
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


The funny thing is that when I copy the actual SQL query generated, Ir runs fine in SQL Server Management Studio and I get the desired reply even if current db is set to a different then RMSUat.

I've tried different tricks around that, but I'm still getting the same exception. Does anybody have any experience with such a configuration? Shed some light on this, please.

thx.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.