Jatin.DUA | 20 Aug 08:09

V important ICrteria Question

Hi Everyone

I am relatively new to Nhibernate. I have been trying to do something using Criteria objects and have found it very hard to do. It’s a relatively simple thing to do using HQL or Sql but we prefer Criteria objects as they retain the mappings.

The problem:

I need to check whether a particular user has a particular role. I try to do the following

using (NHibernate.ISession session = NHibernateSessionManager.Instance.GetSession<UserRelationship>(appSession))
            {
                ICriteria criteria = session.CreateCriteria(typeof(UserRelationship));
                criteria.CreateCriteria("User", "usr", JoinType.LeftOuterJoin);
                criteria.Add(Expression.Eq("usr.Id", userId));
                criteria.CreateCriteria("ExternalRole", "ex", JoinType.LeftOuterJoin);
                criteria.Add(Expression.Eq("ex.Name", roleName));
                relationshipList = criteria.List<UserRelationship>();   
         
                              

            }

but that gives me following error: System.Data.SqlClient.SqlException: The correlation name 'ex1_' is specified multiple times in a FROM clause.

 It works fine when I run the criteria for ClientExternalRoleRelationship as it doesn’t have to join to the ExternalRole table twice but because UserRelationship is a base class for ExternalRoleRelationship and ClientExternalRoleRelationship . How do I tell it not to use same alias twice but to use a different one for each join? I even tried FetchMode.Join etc with the "Role" in the association Path. That works fine but if I then try and provide a filter on the Role object to check for a particluar RoleName nhibernate doesn’t like it and thinks that I am accessing a property on the root object (UserRelationship)

Help will be greatly appreciated.

The mapping files are attached

                                                      .

Classification: UNCLASSIFIED

<<UserRelationship.hbm.xml>> <<ExternalUserRelationships.hbm.xml>> <<InternalUserRelationships.hbm.xml>> <<ProgrammeRole.hbm.xml>> <<Role.hbm.xml>> <<User.hbm.xml>>

Attachment (Role.hbm.xml): text/xml, 3376 bytes
Attachment (User.hbm.xml): text/xml, 5967 bytes
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development

Nhibernate Linq Expression hierarchy

I am planning to modify the expression tree a little bit.
 
NHIbernate.Expression.SqlExpression <- root of the expression tree
 - SelectExpression 
      -From property(Expression: Another SelectExpression(aka subquery) or TableReference(should we define Table Expression?)
      -Where property(Expression: (any expression that can be handled, binary operation with either ColumnExpression or an AggregateSubqueryExpression)
      -Group by expresison (I cant imagine this part, linq allows more grouping than one may expect
      -Orderby expresion( can be an aggregatesubquery or a column expression together with ascending or descending flag)
   - join expression
       - leff - sql expression
       - right - sql expression
       - join condition == conditional expression
 
I have to admit that I have been affected by Wayward's posts
 

--
Tuna Toksöz

Typos included to enhance the readers attention!
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development

linq - how to test expression reducers

Hello team,
I am working on Expression reducers to simplify complex expressions.
I made LogicalExpressionReducer which simply converts not(not(not(true))) to ConstantExpression(false) and (true & x.Name=="johndoe") to (x.Name=="john doe"), meaning that it just uses the truth table to reduce expressions.
 
The problem with expressions is that they are trees! For simple ones, it is easy to check if I get the same result but complex ones are hard to deal with.
I first thought that I can use .ToString() of expression which produces string representation of an expression, that is some thing like Assert.AreEqual("false",reducedExpression.ToString())
 
But this simply sounds incorrect to me. I then thought about using visitors to check for equality, but not sure about that.
 
2nd one sounds the way to go, but are there any simpler way to test it?
 
Producing

--
Tuna Toksöz

Typos included to enhance the readers attention!
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
Ramon | 15 Aug 11:27

Possible bug when HTML/XML is in the column data 2.0.CR2

Hi all,

I am having the following problem:

 - A table where a column has html data.
 - I enabled nhibernate query logging
 - I enabled the SQL profiler.

The query executed on the database is :

exec sp_executesql N'SELECT this_.Language_Id as Language1_19_0_,
this_.Webcast_Id as Webcast2_19_0_, this_.Addon_Id as Addon3_19_0_,
this_.Template_Id as Template4_19_0_, this_.Name as Name19_0_,
this_.Body as Body19_0_, this_.Index_Nr as Index7_19_0_, this_.Custom
as Custom19_0_, this_.LiveStatusVisibility as LiveStat9_19_0_ FROM
AddonBasic this_ WHERE this_.Webcast_Id = @p0 and this_.Language_Id =
@p1 and this_.Addon_Id = @p2', N'@p0 int,@p1 int,@p2 int', @p0 = 1067,
@p1 = 1, @p2 = 1

The query executes fine and has a one row result but NHibernate
crashes and this is the tail of the log:
=[START]============================================
NHibernate: SELECT this_.Language_Id as Language1_19_0_,
this_.Webcast_Id as Webcast2_19_0_, this_.Addon_Id as Addon3_19_0_,
this_.Template_Id as Template4_19_0_, this_.Name as Name19_0_,
this_.Body as Body19_0_, this_.Index_Nr as Index7_19_0_, this_.Custom
as Custom19_0_, this_.LiveStatusVisibility as LiveStat9_19_0_ FROM
AddonBasic this_ WHERE this_.Webcast_Id = @p0 and this_.Language_Id =
@p1 and this_.Addon_Id = @p2; @p0 = '1067', @p1 = '1', @p2 = '1'
TestCase 'ServiceDemoTest.PlayerServiceTest.TestWelcome'
failed: NHibernate.ADOException: could not execute query
[ SELECT this_.Language_Id as Language1_19_0_, this_.Webcast_Id as
Webcast2_19_0_, this_.Addon_Id as Addon3_19_0_, this_.Template_Id as
Template4_19_0_, this_.Name as Name19_0_, this_.Body as Body19_0_,
this_.Index_Nr as Index7_19_0_, this_.Custom as Custom19_0_,
this_.LiveStatusVisibility as LiveStat9_19_0_ FROM AddonBasic this_
WHERE this_.Webcast_Id = ? and this_.Language_Id = ? and
this_.Addon_Id = ? ]
Positional parameters:  #0>1067 #0>Dutch #0>Welcome
[SQL: SELECT this_.Language_Id as Language1_19_0_, this_.Webcast_Id as
Webcast2_19_0_, this_.Addon_Id as Addon3_19_0_, this_.Template_Id as
Template4_19_0_, this_.Name as Name19_0_, this_.Body as Body19_0_,
this_.Index_Nr as Index7_19_0_, this_.Custom as Custom19_0_,
this_.LiveStatusVisibility as LiveStat9_19_0_ FROM AddonBasic this_
WHERE this_.Webcast_Id = ? and this_.Language_Id = ? and
this_.Addon_Id = ?]
	NHibernate.ADOException: could not execute query
	[ SELECT this_.Language_Id as Language1_19_0_, this_.Webcast_Id as
Webcast2_19_0_, this_.Addon_Id as Addon3_19_0_, this_.Template_Id as
Template4_19_0_, this_.Name as Name19_0_, this_.Body as Body19_0_,
this_.Index_Nr as Index7_19_0_, this_.Custom as Custom19_0_,
this_.LiveStatusVisibility as LiveStat9_19_0_ FROM AddonBasic this_
WHERE this_.Webcast_Id = ? and this_.Language_Id = ? and
this_.Addon_Id = ? ]
	Positional parameters:  #0>1067 #0>Dutch #0>Welcome
	[SQL: SELECT this_.Language_Id as Language1_19_0_, this_.Webcast_Id
as Webcast2_19_0_, this_.Addon_Id as Addon3_19_0_, this_.Template_Id
as Template4_19_0_, this_.Name as Name19_0_, this_.Body as Body19_0_,
this_.Index_Nr as Index7_19_0_, this_.Custom as Custom19_0_,
this_.LiveStatusVisibility as LiveStat9_19_0_ FROM AddonBasic this_
WHERE this_.Webcast_Id = ? and this_.Language_Id = ? and
this_.Addon_Id = ?] ---> System.Xml.XmlException: Root element is
missing.
	at System.Xml.XmlTextReaderImpl.Throw(Exception e)
	at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
	at System.Xml.XmlTextReaderImpl.Read()
	at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
	at System.Xml.XmlDocument.Load(XmlReader reader)
	at System.Xml.XmlDocument.LoadXml(String xml)
	at System.Xml.XmlDocument.set_InnerXml(String value)
	C:\svn.metadata\Demo\ServiceDemo\DAL\Webcast.cs(781,0): at
Dal.AddonBasic.set_Custom(String value)
	at (Object , Object[] , SetterCallback )
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Bytecode\Lightweight\AccessOptimizer.cs(32,0):
at NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues(Object
target, Object[] values)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Tuple\Entity\PocoEntityTuplizer.cs(271,0):
at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object
entity, Object[] values)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Tuple\Entity\PocoEntityTuplizer.cs(259,0):
at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValues(Object
entity, Object[] values)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs(3720,0):
at NHibernate.Persister.Entity.AbstractEntityPersister.SetPropertyValues(Object
obj, Object[] values, EntityMode entityMode)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Engine\TwoPhaseLoad.cs(87,0):
at NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity,
Boolean readOnly, ISessionImplementor session, PreLoadEvent
preLoadEvent, PostLoadEvent postLoadEvent)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(617,0):
at NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList
hydratedObjects, Object resultSetId, ISessionImplementor session,
Boolean readOnly)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(466,0):
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(187,0):
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(1803,0):
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters)
	   --- End of inner exception stack trace ---
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(1812,0):
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(1718,0):
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
session, QueryParameters queryParameters)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Loader.cs(1712,0):
at NHibernate.Loader.Loader.List(ISessionImplementor session,
QueryParameters queryParameters, ISet`1 querySpaces, IType[]
resultTypes)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Loader\Criteria\CriteriaLoader.cs(67,0):
at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor
session)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs(1594,0):
at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList
results)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\CriteriaImpl.cs(455,0):
at NHibernate.Impl.CriteriaImpl.List(IList results)
	c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\CriteriaImpl.cs(466,0):
at NHibernate.Impl.CriteriaImpl.List[T]()
=[ END ]============================================

It seems that NHibernate puts the query result in an xml like
structure and the only obvious thing that comes to mind is that the
data returned from the database isn't escaped. The data returned isn't
valid xml (its xml).

I will try to hunt down this exception this weekend with the
nhibernate sources but wanted to this list as I don't know where and
how to report (possible) bugs.

Ramon

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Roger Kratz | 14 Aug 12:50

Update "Operating system" in source forge

Hi

 

Don’t know where to send this, if this is the totally wrong place – I’m sorry.

 

I just want to suggest that you update Sourceforge telling what OS nhib supports. I have the last week got two questions from two different people asking me if nhib supports 64-bit environments. They’ve asked me because they both independently seen on SF that nhib only supports 32-bits environments. I’ve replied to them that I’ve used nhib in 64-bits environments without any issues at all.

 

Maybe it’s a good idea for you to update this entry in SF?

 

Regards

Roger

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
MSNBC Breaking News | 13 Aug 16:43

msnbc.com - BREAKING NEWS: Bomb scare grounds thousands of flights at UK Heathrow airport

msnbc.com: BREAKING NEWS: Bomb scare grounds thousands of flights at UK Heathrow airport

Find out more at http://breakingnews.msnbc.com
======================================================
See the top news of the day at MSNBC.com, and the latest from Today Show and NBC Nightly News.

=========================================
This e-mail is never sent unsolicited. You have received this MSNBC Breaking News Newsletter
newsletter because you subscribed to it or, someone forwarded it to you.
To remove yourself from the list (or to add yourself to the list if this
message was forwarded to you) simply go to
http://www.msnbc.msn.com/id/70582498, select unsubscribe, enter the
email address receiving this message, and click the Go button.

Microsoft Corporation - One Microsoft Way - Redmond, WA 98052
MSN PRIVACY STATEMENT
http://privacy.msn.com (http://privacy.msn.com/>)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
Will Shaver | 13 Aug 06:58

Linq project added to core

It looks like Chad Lee added the NHibernate.Linq project and NHibernate.Linq.Test projects to the vs2008 solution. Cool.
 
I spent a few hours tonight going over Linq to NH project and Reflecting over Linq to SQL. (What a mess that is.)
 
If none of you have read this article here:
 
It seems like a good place to start learning linq.
 
So the current implementation of linq to NH (contrib) appears to do this: (please correct if I'm wrong)
 
NHibernateQueryProvider->Execute(Expression)
 //clean expression, translate nodes to NHibernateExpression type where needed
 //visit all expression creating and appending to an ICriteria for each part of the query.
 //execute the ICriteria
 
Easy enough. We're doing something a bit more complicated this time around...
 
 
NHibernateQueryProvider-> Execute(Expression expression)
   //clean expression tree, translate nodes to NHibernateExpression type where needed. ***                                 
   //this translation is done by consulting the using the SessionFactory for metadata on each item in the expression
 
option1:
   //Translate NHExpression to SqlString here?
   //Pass SqlString to Dialect for translation  (Things like factory.Dialect.GetLimitString(sql string))
 
option2:
  //Pass NHExpression to the Dialect for limit strings ect,
public virtual SqlString GetLimitString(SqlString querySqlString, bool hasOffset)
  becomes
public virtual NHibernateExpression ProcessLimitString(NHibernateExpression expression)
Which our translator calls to add in that dialect's specific limit string and other quirks.
 
  //Then take the SqlString and process into entities and return as done in Loader... Or put processing of the NHibernateExpression in Loader?
 
Let me know what you folks think.   
 
***Linq To SQL appears to translate to a different tree type that is not inherited from Expression, but contains an Expression property. Perhaps there is a good reason for this? Review SqlNode in System.Data.Linq.SqlClient via Reflector. Ironically they also have a direct copy and paste of the internal marked ExpressionVisitor class in here as well...
 
 -Will
 
 
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
CNN Alerts | 12 Aug 10:25

CNN Alerts: My Custom Alert

Alert Name: My Custom Alert

Rape allegations force Afghan gov't crackdown
Tue, 12 Aug 2008 10:27:20 +0200

FULL STORY

You have agreed to receive this email from CNN.com as a result of your CNN.com preference settings.
To manage your settings click here.
To alter your alert criteria or frequency or to unsubscribe from receiving custom email alerts, click here.

Cable News Network. One CNN Center, Atlanta, Georgia 30303
© 2008 Cable News Network.
A Time Warner Company
All Rights Reserved.
View our privacy policy and terms.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
Maggit Irzyk | 12 Aug 08:04

Boy takes off Favre jersey after 4 yrs

Bonjour,



Vd I A Gm R rA

WW V LEF.C
W. O OM
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
Fabio Maulo | 11 Aug 21:16

New NH Committers

Chad Lee and Tuna are new committers in NH core.

Chad, Will and Tuna will work on the new implementation of LINQ2NH.

Have a great future with new NH features !!

WELLCOME GUYS!!

Fabio Maulo
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
CNN Alerts | 11 Aug 13:48

CNN Alerts: My Custom Alert

Alert Name: My Custom Alert

Apple iPhone price drops to $150
Mon, 11 Aug 2008 19:52:06 +0800

FULL STORY

You have agreed to receive this email from CNN.com as a result of your CNN.com preference settings.
To manage your settings click here.
To alter your alert criteria or frequency or to unsubscribe from receiving custom email alerts, click here.

Cable News Network. One CNN Center, Atlanta, Georgia 30303
© 2008 Cable News Network.
A Time Warner Company
All Rights Reserved.
View our privacy policy and terms.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development

Gmane