Does NHibernate 3.0.0.4000 handle bools differently in requests?

I just updated nHibernate from version 3.0.0.1002 to 3.0.0.4000. As soon as I did this, many of my requests started to crash. One such request:

var items = (from b in session.Query<InvoiceDetail>() 
                            where b.Customer == AddressedToCustomer && b.IsCreditNote == !addInvoices 
                            orderby b.DueDate , b.InvoiceNumber 
                            select b).ToList(); 

SQL Generated in Version 3.0.0.1002:

2011-02-17 15: 55: 43.612 as the choice of DEBUG invoicedet0_.Id Id3_, invoicedet0_.InvoiceNumber as InvoiceN2_3_, invoicedet0_.DocumentNumber how Document3_3_, invoicedet0_.DocumentDate how Dokument4_3_, invoicedet0_.DueDate how DueDate3_, invoicedet0_.DivisionDetails as Razdel6_3_, invoicedet0_. IsInvoice like IsInvoice3_, invoicedet0_.IsCreditNote as IsCredit8_3_, invoicedet0_.OriginalAmount as Original9_3_, invoicedet0_.Amount as Amount3_, invoicedet0_.LRNo like LRNo3_, invoicedet0_.LRDate like LRDate3_, invoicedet0_.DispatchedBy as Dispatc13_3_, invoicedet0_.CreditDays like CreditDays3_, invoicedet0_.CustomerId as CustomerId3_ of InvoiceDetails invoicedet0_ where ((invoicedet0_.CustomerId is null) and (@ p0 is null) or invoicedet0_.CustomerId=@p0) and the case when invoicedet0_.IsCreditNote = 1, then 1 else 0 end = case, when @ p1 = 1, then 1 else 0 end order by invoicedet0_.DueDate asc, invoicedet0_.InvoiceNumber asc; @ p0 = 101790 [Type: Int32 (0)], @ p1 = False [Type: Int32 (0)]

SQL Generated in Version 3.0.0.4000:

2011-02-17 16: 22: 15,275 DEBUG invoicedet0_.Id Id3_, invoicedet0_.InvoiceNumber as InvoiceN2_3_, invoicedet0_.DocumentNumber Document3_3_, invoicedet0_.DocumentDate 4_3_, invoicedet0_.DueDate DueDate3_, invoicedet0_.DivisionDetails as 6_3_, invoicedet0_.IsInvoice IsInvoice3_, invoicedet0_.IsCreditNote as IsCredit8_3_, invoicedet0_.OriginalAmount as Original9_3_, invoicedet0_.Amount as Amount3_, invoicedet0_.LRNo LRNo3_, invoicedet0_.LRDate LRDate3_, invoicedet0_.DispatchedBy as Dispatc13_3_, invoicedet0_.CreditDays CreditDays3_, invoicedet0_.CustomerId as CustomerId3_ InvoiceDetails invoicedet0_ invoicedet0_.CustomerId=@p0 case invoicedet0_.IsCreditNote = 1, 'true' else 'false' end = case, @p1 = 'true', 'true' else 'false' end order by invoicedet0_.DueDate asc, invoicedet0_.InvoiceNumber asc; @p0 = 101790 [: Int32 (0)], @p1 = 'False' [: String (0)]

bools ints (true = 1, false = 0). , - . Bool , int .

SQL:
"! addInvoices " sql- int :
3.0.0.1002: @p1 = True [: Int32 (0)]
3.0.0.4000: @p1 = 'True' [: String (0)]

, IsCreditNote "true" "false" 1 0 .

-, , 3.0.0.4000:
:

2011-02-20 10: 18: 22 977 DEBUG INSERT INTO InvoiceDetails (InvoiceNumber, DocumentNumber, DocumentDate, DueDate, DivisionDetails, IsInvoice, IsCreditNote, OriginalAmount, Amount, LRNo, LRDate, DispatchedBy, CreditDays, CustomerId) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13); last_insert_rowid(); @p0 = 9070183358 [: Int64 (0)], @p1 = 28592879 [: Int64 (0)], @p2 = '20110210' [: String (0)], @p3 = '20110303' [: String (0)], @p4 = NULL [: String (0)], @p5 = True [: Boolean (0)], @p6 = False [: Boolean (0)], @p7 = 2685 [: (0)], @p8 = 2685 [: (0)], @p9 = NULL [: (0)], @p10 = NULL [: String (0)], @p11 = NULL [: String (0)], @p12 = 21 [: Int32 (0)], @p13 = 101760 [: Int32 (0)]

Update:

2011-02-20 10: 10: 13,941 DEBUG invoicedet0_.Id Id3_, invoicedet0_.InvoiceNumber as InvoiceN2_3_, invoicedet0_.DocumentNumber Document3_3_, invoicedet0_.DocumentDate 4_3_, invoicedet0_.DueDate DueDate3_, invoicedet0_.DivisionDetails as 6_3_, invoicedet0_.IsInvoice IsInvoice3_, invoicedet0_.IsCreditNote as IsCredit8_3_, invoicedet0_.OriginalAmount as Original9_3_, invoicedet0_.Amount as Amount3_, invoicedet0_.LRNo LRNo3_, invoicedet0_.LRDate LRDate3_, invoicedet0_.DispatchedBy as Dispatc13_3_, invoicedet0_.CreditDays CreditDays3_, invoicedet0_.CustomerId as CustomerId3_ InvoiceDetails invoicedet0_ invoicedet0_.CustomerId=@p0 case invoicedet0_.IsCreditNote = 1, 'true' else 'false' end = case, @p1 = 'true', 'true' else 'false' end order by invoicedet0_.DueDate asc, invoicedet0_.InvoiceNumber asc; @p0 = 107233 [: Int32 (0)], @p1 = 'True' [: String (0)]

(@p6), Selects - (@p1).

, nHibernate JIRA ( ), Patrick . , .

nHibernate . -. - , , ?

EDIT:
SQLite, Fluent nHibernate.

+3
2

. /LINQ .

API /QueryOver :

var items = session.QueryOver<InvoiceDetail>()
        .Where(i => i.Customer == AddressedToCustomer)
        .And(i => i.IsCreditNote != addInvoices)
        .OrderBy(i => i.DueDate).Asc
        .ThenBy(i => i.InvoiceNumber).Asc
        .List();

, / -, . Query<> QueryOver<>, . , nHibernate, , , , linq.

+1

:

SQL- .

:

3.5.4. Query Language Substitution

You may define new NHibernate query tokens using query.substitutions. For example:
query.substitutions true=1, false=0
would cause the tokens true and false to be translated to integer literals in the generated SQL.
query.substitutions toLowercase=LOWER
would allow you to rename the SQL LOWER function.
0

Source: https://habr.com/ru/post/1793532/


All Articles