开发者

NHibernate's format_sql property (not that) pretty printing

Comparing the following output with samples I've seen here at Stack Overflow and over the internet makes me wonder what am I doing wrong, as apparently both the show_sql and format_sql properties are correctly set?

Output

NHibernate:
    SELECT
        book0_.Isbn as Isbn0_0_,
        book0_.Title as Title0_0_,
        book0_.Author as Author0_0_,
        book0_.Publisher as Publisher0_0_,
        book0_.Published as Published0_0_,
        book0_.Pages as Pages0_0_,
        book0_.InStock as InStock0_0_,
        book0_.Description as Descript8_0_0_
    FROM
        Books book0_
    WHERE
        book0_.Isbn=@p0;
    @p0 = '0596800959' [Type: String (0)]

Book.cs

public class Book
{
    public string Isbn { get; set; }
    public string Title { get; set; }
    public string Author { get; set; }
    public string Publisher { get; set; }
    public DateTime Published { get; set; }
    public int? Pages { get; set; }
    public bool InStock { get; set; }
    public string Description { get; set; }
}

Book.hbm.xml

<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="Dotnet.Samples.NHibernate"
                   namespace="Dotnet.Samples.NHibernate">
  <class name="Book" table="Books" lazy="false">
    <id name="Isbn" />
    <property name="Title" />
    <property name="Author" />
    <property name="Publisher" />
    <property name="Published" />
    <property name="Pages" />
    <property name="InStock" />
    <property name="Description" />
  </class>
</hibernate-mapping>

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
    <property name="connection.connection_string">Data Source=res/Catalog.sdf</property>
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.Pr开发者_运维技巧oxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
  </session-factory>
</hibernate-configuration>

Any advice will be really appreciated. Thanks much in advance.

UPDATE

In response to comments I'm adding how the expected output should look like (basically a valid SQL statement):

NHibernate:
    SELECT
        Isbn,
        Title,
        Author,
        Publisher,
        Published,
        Pages,
        InStock,
        Description
    FROM
        Books
    WHERE
        Isbn = '0596800959'


Are you using the latest version of NHibernate? This is the original task. This blog implies that it is only supported in 3.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜